cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

slice of a 3D surface

payman
13-Aquamarine

slice of a 3D surface

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

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To: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.

 

View solution in original post

13 REPLIES 13
Werner_E
24-Ruby V
(To:payman)

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:

Werner_E_2-1626346229326.png

 

(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

 

payman
13-Aquamarine
(To:Werner_E)

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.

 

 

 

Werner_E
24-Ruby V
(To: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).

Werner_E_0-1626546123904.png

And in case Valery is watching ... 🙂

slicer2.gif

MC15 sheet attached

 

payman
13-Aquamarine
(To:Werner_E)

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

payman_0-1626637699165.png

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_2-1626638401541.png

 

Werner_E
24-Ruby V
(To: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 😉

payman
13-Aquamarine
(To:Werner_E)

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.

 

ttokoro
20-Turquoise
(To:payman)

image.png

Prime 7

payman
13-Aquamarine
(To:ttokoro)

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.

ttokoro
20-Turquoise
(To: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.

ttokoro
20-Turquoise
(To:payman)

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.) 

 

image.png

ttokoro
20-Turquoise
(To:ttokoro)

ttokoro_0-1626821619313.png

ttokoro_1-1626821668216.png

ttokoro_3-1626821815938.png

ttokoro_4-1626821861792.png

 

 

 

image.pngimage.png

Top Tags