Retrieve orthogonal coordinate curves from interpolated surface
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Problem:
I'm trying to generate a pattern, which is well definable in cartesian coordinates on some curved survace, while longitudinal characteristics of the pattern would be preserved. (One could think for example on engraving a text on some surface)
EXAMPLE (straight line l=1 on the surface):
Assume a generic Spline-fitted surface
(for example, surface fit from spap2 documentation):
%% surface fit example spap2
x = -2:.2:2;
y = -1:.25:1;
[xx, yy] = ndgrid(x,y);
z = exp(-(xx.^2+yy.^2));
figure
sp = spap2({augknt([-2:2],3),augknt([-2:2],3)},8,{x,y},z);
fnplt(sp)
Result of the surface fit with spap2 allows us now to interpolate the cartesian z coordinate on the surface by calling fnval.
Line on this surface
Now let's define a straight line [0 0.5] -> [1 0.5] with length of 1 in cartesian xy coordinates, interpolate the z-coordinate and plot it in the same figure
%% plot line on the surface
hold on
lin_x = linspace(0,1,30);
lin_y = linspace(.5,.5,30);
lin_z = fnval(sp,[lin_x;lin_y]);
plot3(lin_x,lin_y,lin_z,'r','LineWidth',2)
Both code section above results in following:
This line have a length of 1 only if z0->z1 is a straight line.
The possibility to define some line with a specific length in such plane woud be to use curvilinear coordinates where instead of straight orthogonal x and y vectors, (orthogonal) curves x(u) and y(v) are used, where u and v represent the distance along the x and y curve
Question:
how to use curvilinear coordinates properly under these circumstances?
What would be the best way to retrieve a set of orthogonal coordinate curves for describing coordinates in this plane in a curvilinear manner?
An approach I'm currently thinking about would be:
- Consider some origin point O on the plane
- Consider direction of the first coordinate curve x(u) in cartesian coordinates
- Sample a set of points in cartesian X0-plane from surface. fit a spline or use directly as linear interpolated curve
- Interpolate a point x(1) along this curve exactly 1 unit away from origin e.g. by using interparc
- Estimate the normal vector n to the surface on point x(1)
- compute orthogonal direction for y(v) as cross product from x(u) and n
- Sample a set of points in cartesian plane (where the curve O->y(v) is located) from surface. fit a spline or use directly as linear interpolated curve
- repeat Steps 4-7 for points between x(0) y(0) and x(1) y(1) for z-interpolation and plotting
However i'm not sure if I'm reinventing a bicycle rigth now and if there is some more elegant solution for 3D curvilinear coordinates in MATLAB.
Thanks for any Valuable input and considaretions in Advance!
2 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Spline Postprocessing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!