将平面弯曲成圆锥形表面 [英] Bending a plane into a conical surface
问题描述
我目前正在尝试在Matlab上计算折纸结构,并且我正在寻找一种方法来使我的折痕图案弯曲在圆锥形表面上,其方式与此答案相同:
I am currently trying to compute Origami structures on Matlab, and I am looking for a method to bend my crease patterns on a conical surface, in the same way that this answer : Bending a plane into a closed surface/cylinder into a cylinder.
请问我该怎么做?
干杯
推荐答案
您只需要将(x,y)坐标映射到圆锥形表面的3D坐标即可.因此,要做到这一点,重要的是根据两个变量对圆锥形表面进行参数化.因此:
You should just have to map an (x,y) coordinate into a 3D coordinate for a conical surface. So to do this, it is important to parametrize a conical surface as a function of two variables. Thus:
(r,theta,z)=( a * z + c ,theta,z)对于某些 a , c 您定义
( r, theta, z ) = ( a * z + c, theta, z ) for some a,c you define
然后,您只需要在(x,y)和(theta,z)之间创建关系,以便可以找到作为(x,y)的函数的给定(theta,z).然后归结为一组简单的for循环,以循环遍历(x,y)点以找到圆锥面上的映射坐标.
Then you just need to create a relationship between (x,y) and (theta,z) so you can find a given (theta,z) as a function of (x,y). Then it comes down to a simple set of for loops to iterate through the (x,y) points to find the mapped coordinates on the conical surface.
===编辑===
所以我写了一些代码来说明映射有多简单.首先,这是一些图像.第一个是要映射的平面网格,第二个图像是结果.
So I wrote some codes to illustrate how simple the mapping can be. First, here are some images. The first is the planar mesh that will be mapped, and the second image is the result.
% This is file: gen_mesh.m
function [x, y, tri_mesh] = gen_mesh()
% Initialize output coordinates of points that make up the mesh
y = [];
x = [];
% Initialize mesh
tri_mesh= [];
% Number of points in the x dimension
Nx = 5;
% Number of points in the y dimension
Ny = 17;
% For this mesh, make each row have a slightly
% different number of points
x1 = linspace(0,1,Nx);
dx = x1(2)-x1(1);
x2 = linspace(dx/2, 1-dx/2, Nx-1);
% Create the array with the y values
y1 = linspace(0,1,Ny);
%% Generate the associated (x,y) pairs
for iy = 1:Ny
if( mod(iy,2) == 0 )
y = [y, ones(1,Nx-1)*y1(iy)];
x = [x, x2];
else
y = [y, ones(1,Nx)*y1(iy)];
x = [x, x1];
end
end
%% Generate the Mesh of triangles
% Make sure that the mesh wraps to each
% opposite x bound. This is to make sure that
% the cyclic nature of the conical surface
% doesnt mess up the look of the mesh
count = 1;
curr = 1;
ol = [];
el = [];
for iy = 1:Ny
if( mod(iy, 2) == 0 )
el.x = x(curr:curr+(Nx-2));
el.y = y(curr:curr+(Nx-2));
else
ol.x = x(curr:curr + Nx - 1);
ol.y = y(curr:curr + Nx - 1);
end
if( iy ~= 1 )
for i = 2:Nx
tri_mesh(count).x = [ol.x(i), el.x(i-1), ol.x(i-1)];
tri_mesh(count).y = [ol.y(i), el.y(i-1), ol.y(i-1)];
count = count + 1;
end
for i = 2:(Nx-1)
tri_mesh(count).x = [el.x(i), ol.x(i), el.x(i-1)];
tri_mesh(count).y = [el.y(i), ol.y(i), el.y(i-1)];
count = count + 1;
end
tri_mesh(count).x = [el.x(1), ol.x(1), el.x(end)];
tri_mesh(count).y = [el.y(1), ol.y(1), el.y(end)];
count = count + 1;
end
if( mod(iy, 2) == 0 )
curr = curr + (Nx-1);
else
curr = curr + Nx;
end
end
end
% This is file: map_2D_to_3DCone.m
function [xh, yh, z] = map_2D_to_3DCone( x, x_rng, y, y_rng )
% x: an array of x values part of a planar coordinate
%
% x_rng: the smallest and largest possible x values in the planar domain
% -> x_rng = [min_x, max_x]
%
% y: an array of y values part of a planar coordinate
%
% y_rng: the smallest and largest possible y values in the planar domain
% -> y_rng = [min_y, max_y]
% The bottom z (height) value
zb = 0;
% The top z value
zt = 1;
% The radius value at z = zb
rb = 3;
% The radius value at z = zt
rt = 1;
%% Obtain the Conical Surface 3D coordinates
% Find z as a function of y in the planar domain
% This mapping is a simple 1-D Lagrange interpolation
z = (zt*( y - y_rng(1) ) - zb*( y - y_rng(2) ))/(diff(y_rng));
% Find the parametrized angle as a function of x
% using a 1D Lagrange interpolation
theta = 2*pi*( x - x_rng(1) )/(diff(x_rng));
% Find the radius as a function of z using
% a simple 1D legrange interpolation
r = ( rt*(z - zb) - rb*(z - zt) )/( zt - zb );
% Find the absolute x and y components of the
% 3D conical coordinates
xh = r.*cos(theta);
yh = r.*sin(theta);
end
% This is in file: PlaneMesh_to_ConicalMesh.m
function mesh3d = PlaneMesh_to_ConicalMesh( mesh2d )
% Generate the 3D version of each planar triangle, based
% on the mapping function that takes an (x,y) planar
% coordinate and maps it onto a conical surface
N = length(mesh2d);
mesh3d(N).x = [];
mesh3d(N).y = [];
mesh3d(N).z = [];
for i = 1:N
[xh, yh, z] = map_2D_to_3DCone( mesh2d(i).x, [0,1], mesh2d(i).y, [0,1] );
mesh3d(i).x = xh;
mesh3d(i).y = yh;
mesh3d(i).z = z;
end
end
% This is in file: gen3D_MappedCone.m
% Generate the 3D object
close all
% Generate a 2D planar mesh to morph onto
% a conical surface
[x, y, mesh2d] = gen_mesh();
% Map the 2D mesh into a 3D one based on the
% planar to conical surface mapping
mesh3d = PlaneMesh_to_ConicalMesh( mesh2d );
% Obtain the number of triangles making up
% the mesh
N = length(mesh3d);
% Define a color mapping function for the sake
% of visualizing the mapping
color_map = @(x) [1, 0, 0].*(1-x) + [0, 0, 1].*x;
% Create the first image based on the planar
% mesh
figure(1)
hold on
for i = 1:N
color = color_map( (i-1)/(N-1) );
h = fill( mesh2d(i).x,mesh2d(i).y, color );
set(h, 'facealpha',0.9)
end
axis([0,1,0,1])
% Create the next figure showing the 3D mesh
% based on the planar to conical surface transformation
figure(2)
hold on
for i = 1:N
color = color_map( (i-1)/(N-1) );
h = fill3(mesh3d(i).x,mesh3d(i).y,mesh3d(i).z, color);
set(h, 'facealpha',0.9)
end
grid on
hold off
这篇关于将平面弯曲成圆锥形表面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!