Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hello everyone,
The data points of a 3D surface are supplied in the accompanying worksheet. I'm looking for a slice of the surface at any azimuth angle. Through interpolation, I was able to extract the function that describes the surface. The function slice(phi) was subsequently constructed to slice the surface at any angle phi. Due to missing points on the original data on the rim, the interpolated function shows irrational behavior around the edges (except at zero and half-pi angle). In this example, the rim is a circle of diameter of 15.8.
What are your recommendations for dealing with this issue?
I am grateful for your aid.
Best,
Payman
Solved! Go to Solution.
Here is a further attempt of mine. This time I scan through the data in x-direction and replace the outer zero values by the linear interpolated (extrapolation actually) using only the non-zero values. Its still not perfect, but I guess its better than the first attempt.
I still think that, assuming we really have to deal with a quadric, a fit of an appropriate function might be the better approach.
If its not a quadric but rather just a similarly looking arbitrary surface, you'll have to stick with the data and its interpolations, of course.
I guess the problem is the abrupt jump of the data at the rim from the paraboloid(?) surface down to the zero ground in combination with the spline interpolation which tends to overshoot in such cases .
It looks like linear interpolation does a better job:
(changed "slice" so that the angle with the correct unit degree can be used)
The artefact you still see could be avoided by making the value of "edge" slightly smaller, if thats appropriate.
BTW, if you know that the surface should be a paraboloid, you could try fitting an appropriate function instead of an interpolation.
MC15 sheet attached
Thank you for your suggestions, Werner E.
linterp, as you indicated, helped to improve the issue. I wrote a piece of code to replace the zeros on the surrounding area with NaN. As a result, the outliers are now removed, but the margins of the slices are missing. I know the edges must end up in -3.7 in this example, but I couldn't add it manually.
It's worth mentioning that when I tested spline and fitting algorithms with data that contained NaN, they failed.
Thank you,
Payman.
Here is a further attempt of mine. This time I scan through the data in x-direction and replace the outer zero values by the linear interpolated (extrapolation actually) using only the non-zero values. Its still not perfect, but I guess its better than the first attempt.
I still think that, assuming we really have to deal with a quadric, a fit of an appropriate function might be the better approach.
If its not a quadric but rather just a similarly looking arbitrary surface, you'll have to stick with the data and its interpolations, of course.
And here is yet another approach. I fitted a quadric function to the data. I tried with a generic quadric (6 parameters) and also a parboloid of rotation (just one parameter if we assume the apex at the origin and the z-axis as the axis of rotation).
And in case Valery is watching ... 🙂
MC15 sheet attached
Werner_E, I'm writing to thank you for everything you've done. Your posts always contain new techniques to learn.
Just a quick note on the fitting approach. You may have noticed that the surface given in the worksheet is not a smooth surface. Fitting a single quadratic model hides minor details of the shape (the attached plot). I tried to follow your approach by stacking several quadratic functions for different regions as
This results in a more accurate match with the original data. According to my research, the Zernike polynomials and the biconic model are the best techniques for fitting to the cornea which will be the next phase of my project.
All the best,
Payman.
@payman wrote:
Werner_E, I'm writing to thank you for everything you've done. Your posts always contain new techniques to learn.
So do I - I never heard of Zernike polynomials before.
Glad you found a way to fit an appropriate surface to your data.
Fitting a function is nice as it gives you the sharp edge contour you were looking for, but its also dangereous if you chose an inappropriate of fitting function type. Knowing were the data stems from and what kind of function it basically should follow helps a lot of course.
Actually I had not compared the original data to the quadratic fit into detail and so I did not notice the slight ripples in the original data 😉
Thank you very much, Werner E.
As the most appropriate answer, I favor the one you offered in this post. More research is needed for the fitting approach, which will be done in the future.
Prime 7
Thank you very much ttokoro; It looks great.
Is it possible to provide a quick description of the procedure or post the worksheet?
best,
Payman.
Just add yellow programs to WE's sheet and converted to Prime 7 format.
The argument of "slice" should be an angle, not a horizontal or vertical distance. I guess you are also cheating a little bit as you use a smaller value for "edge" in one of your slice functions which means that it doesn't show the desired edge at all 😉
@payman You'll want to notice that, while Prime's 3D capabilities are way below the (also quite limited) ones of MC15, there is one advantage in Prime: It doesn't choke on NaN's (as the MC15 3D plot does) but rather ignores them and shows the rest.
Slice of sphere by projection of circle and alpha. 🙂
Solved: two straight lines projection on a sphere - PTC Community (WE's post for MFra is modified.)