I think it might be better to just make the CAD software create the spline through the points I have. Thanks to everyone who replied and helped :)
How to obtain a function through 3d points
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I would like to obtain the function of a 3D curve (in my case, a helix) that fits a list of points of (x, y, z) coordinates, so that I can feed this function into a CAD program and obtain a swept extrusion. I'm trying this route so that I can obtain a customizable helix (edit: the points' coordinates have been generated through matlab as already belonging to a helix, just not a regular helix).
I have already taken a look at plotting 3D splines but I don't really need the Matlab plot, I need the function's expression so that I can draw it in CAD.
I haven't been able to find anything like so yet, I would be glad if anyone could point me in the right direction (even just the right documentation page would be fine). Thanks
Antworten (3)
John D'Errico
am 1 Aug. 2023
Obtaining the general "function" of some arbitrary set of points as a curve is essentially impossible to know, as there are infinitely many curves that will pass through any set of points. You can try to use curve fitting techniques, but you need to know the appropriate model.
I would strongly suggest that you are not looking to fit some general helix function to a set of points. Instead, I think you just need to understand how to create a helix, that has some desired set of properties.
A simple helix is easy to build. First, how do you create a circle? WORK IN POLAR COORDINATES.
t = linspace(0,2*pi);
x = cos(t);
y = sin(t);
Clearly, the pairs (x,y) represent points on the perimeter of a circle. Had I made t go further out, a circle is periodic. So the points would just keep on wrapping around. Trig functions are periodic, after all.
But now introduce a z-component, and I will go out further.
t = linspace(0,10*pi);
r = 1;
c = [0,0];
h = 3;
x = c(1) + r*cos(t);
y = c(2) + r*sin(t);
z = t/h;
plot3(x,y,z,'-o')
axis equal
grid on
box on
As you can see, I have created a simple helix. Changing the values of r and h will correspondingly change the general look of that curve, or translate it around, in the case of c. It is just as easy to create a heliz with varying properties along the z axis. For example, an elliptical helix that grows as z increases? Easy peasy.
rx = @(t) t;
ry = @(t) 2*t;
x = c(1) + rx(t).*cos(t);
y = c(2) + ry(t).*sin(t);
h = 0.5;
z = t/h;
plot3(x,y,z,'-o')
axis equal
grid on
box on
Anyway, I think what you need to understand is how to build a heix that does what you want.
5 Kommentare
John D'Errico
am 2 Aug. 2023
Ok, I'm a little confused. If you are using something to generate the helix points, then implicitly you have a function that generates them. It should not be necessary to build some polynomial, or anything. So where do they come from, and how do you control that tool? You do say you can control the density of the points.
Matt J
am 1 Aug. 2023
Bearbeitet: Matt J
am 1 Aug. 2023
I would like to obtain the function of a 3D curve (in my case, a helix) that fits a list of points of (x, y, z) coordinates
Then, it is a data-fitting problem? If so, I would recommend first using cylindricalFit() from this FEX download,
This will let you fit the cylinder on which the helix is wound, and so determine its radius and 3D axis, assuming both are unknown. A direct example of this can be found under the Examples tab, Section Post-Sampling a Cylinder Fit.
Once you have fit the cylinder, you can perform a coordinate rotation so that the helix is parallel to the z-axis Once, you've done that you can solve for the pitch, c, by solving the over-determined parametric equations for an upright helix,

Image Analyst
am 1 Aug. 2023
Like John and Matt have been saying, you need to parameterize your curve, like have x, y, and z all be a function of the same parameter t. So if you have that -- 3 vectors of the same length, one for x, one for y, and one for z and they're all synced up (meaning x(1) goes with y(1) and z(1) and so on), then you can just interpolate each x, y, ans z independently to get the curve. Here's one of my canned, prior demos (which may not do exactly what you want but you could adapt it). It does spline interpolation.


7 Kommentare
Image Analyst
am 3 Aug. 2023
I think you might also have to built into the model how you expect the radius to change as it rises. For example, is the radius expected to be constant with z, or increate linearly or quadratically with z? If it's not constant, then it could get pretty tricky.
Siehe auch
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

