Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 07:51:45 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Finding the closest point on the surface of a 3D ellipsoid
Pages: 1 [2]
Print
Author Topic: Finding the closest point on the surface of a 3D ellipsoid  (Read 3678 times)
raigan
Level 5
*****


View Profile
« Reply #20 on: December 11, 2018, 11:50:05 PM »

I don't know of any automated approaches for 3D sadly; also I assumed you were using this to model a player character or similar dynamic object.. it sounds like that's not the case!

I think the iquilez approach may be the simplest solution, if you can find a way to iterate towards the surface; he uses those distance functions in an iterative context, so I'm guessing that while the formula is only a bound, it's a bound which converges on the true solution the closer you start from it.

This means:
1) start at your query point
2) calculate the distance and the closest point/normal
3) move the query point along the normal by the given distance
4) go to (1) unless things have converged (eg the reported distance is below some threshold)

The hard part will be generating a closest point/normal from a scalar distance value, however he's written an article about that too Wink https://www.iquilezles.org/www/articles/normalsSDF/normalsSDF.htm





Logged
nova++
Level 4
****


Real life space alien (not fake)


View Profile
« Reply #21 on: December 12, 2018, 01:12:46 AM »

I don't know of any automated approaches for 3D sadly; also I assumed you were using this to model a player character or similar dynamic object.. it sounds like that's not the case!

I think the iquilez approach may be the simplest solution, if you can find a way to iterate towards the surface; he uses those distance functions in an iterative context, so I'm guessing that while the formula is only a bound, it's a bound which converges on the true solution the closer you start from it.

This means:
1) start at your query point
2) calculate the distance and the closest point/normal
3) move the query point along the normal by the given distance
4) go to (1) unless things have converged (eg the reported distance is below some threshold)

The hard part will be generating a closest point/normal from a scalar distance value, however he's written an article about that too Wink https://www.iquilezles.org/www/articles/normalsSDF/normalsSDF.htm


Ohhhhh I hadn't even thought of trying that solution iteratively... I'll definitely do some experimentation with it. Scalar-to-vector looks like a serious pain since I have to find a position that's not in-line with the object center. But it's a more comprehensible and straightforward lead than I've found thus far.
Logged

nova++
Level 4
****


Real life space alien (not fake)


View Profile
« Reply #22 on: December 12, 2018, 04:15:21 AM »

It's... it's working.



I'm gonna fall out of my chair. It's WORKING.



Thank you so much. I just set up an iterative function like you said - get the normal, project downward by the distance, feed that back in for X iterations. You don't even need that many - just 2-3 is enough. It has some weirdness at long distances for heavy elongations, but that's a walk in the park compared to getting to this point.


Logged

raigan
Level 5
*****


View Profile
« Reply #23 on: December 12, 2018, 09:30:50 AM »

haha nice! I'm glad that works -- don't thank me, thank the amazing iquilez Smiley
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic