Closed Thread Icon

Topic awaiting preservation: Math: Help with Ellipsoid (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25072" title="Pages that link to Topic awaiting preservation: Math: Help with Ellipsoid (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Math: Help with Ellipsoid <span class="small">(Page 1 of 1)</span>\

 
warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 02-21-2005 16:15

Stuff from here:
http://mathworld.wolfram.com/Ellipsoid.html

Let's say I have an ellipsoid at (0,0,0)
a, b, c are known

Given point (x,y,z), how do I figure out of it's in the ellipsoid?

I'm thinking...

First, find the distance from (0,0,0) to (x,y,z).
Call this testDistance.

Since z is known, use:
z = c*cos(t1)
to solve for t1.
Then use
x = a*cos(t1)*sin(t2)
to solve for t2.

Now that t1 and t2 are known, use the big formula to solve for r.

Then compare r and testDistance.
That should tell me if (x,y,z) is within the ellipsoid.

Is this thinking correct?
If it is, how do I solve for r in the really big equation?
(I'm so rusty at this I'm almost ashamed.)

Help mucho appreciated.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 02-21-2005 16:32

Why not simply injecting your x, y, z in the equation :

code:
x^2   y^2   z^2
--- + --- + --- = 1
a^2 b^2 c^2

If the result is 1 the point is on the surface of the ellipsoid, if it's > 1 the point is outside, finally if it's > 1 the point is inside.

Since you have the coordinates of your point in a cartesian coordinate system, why transforming everything to spherical coordinates ?
And of cours the 1/(a^2), 1/(b^2) and 1/(c^2) can be preprocessed and to turn the equation into :

code:
A * x^2 + B * y^2 + C * z^2 = 1





(Edited by poi on 02-21-2005 16:37)

warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 02-21-2005 16:54

Excellant, poi.
I should pull out my old textbooks and give myself a refresher.

Quick question about scale.

Let's say I run through the equation and the return is 0.5.
This means that (x,y,z) is half way between the center of the ellipsoid and the surface of the ellipsoid.
Correct?

I'm mixing systems a bit because:
(x,y,z) = (R,G,B)
But I want to do things based on roundish things instead of lines/planes/boxes.

Hopefully I'll have something to show in a few days.
What I'm up to will be more apparent.
I've already some some preliminary with a box and I'm very pleased.
However, I want to get rid of the damn corners.

(Edited by warjournal on 02-21-2005 16:56)

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 02-21-2005 17:42
quote:
Let's say I run through the equation and the return is 0.5.
This means that (x,y,z) is half way between the center of the ellipsoid and the surface of the ellipsoid.
Correct?

I'm tempted to say yes. But I'm quite rusty too, so I can't exactly proove it.

But imagine your assumption is correct. It'd meand that you have point whose coords when injected in the equation of the ellipsoid return 0.5 is half way between the center and the surface. So if it really is half way, multiplying those coords by 2^.5 ( the ^.5 is there to compensate the fact that all factors are squared in the equation of the ellipsoid ) should lead us right on the surface.

So let's take an example with the following values :

a = 2
b = 8
c = 4

Eq( x, y, z ) = ( x^2 )/4 + ( y^2 )/64 + ( z^2 )/ 16

if we take the point ( 0.5 , 2 , 6^.5 ) and inject it in Eq( x, y, z ) we get : 0.5

Now if the mutliply the coords of our point 2^.5 we have the point ( (2^.5)/2 , (2^.5)*2, (2^.5)*(6^.5) ). Once injected in Eq( x, y, z ) we now have : 1



(Edited by poi on 02-21-2005 17:48)

warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 02-21-2005 18:38

Maybe we should start a support group.
Wait... this is a support group.

So far just a threshhold test and it seems to be working dandy.
Now I have to figure out fall-off and the scales for that.
Ugh!


The hard part about this if figuring out the particulars of Filter Meister.
a^2
pow(a,2)
sqr(a)
Can not be used interchangably.
Damn nuances.
Then again, I do need to take a closer look into data types.

Kudos.

warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 02-21-2005 19:25
code:
testDist=(((dR-R)^2)/(aa^2))+(((dG-G)^2)/(bb^2))+( ((dB-B)^2)/(cc^2));

if (testDist<=1 && testDist>=0.0)



1. All of the parenthesis are necessary.
2. Apparently testDist can come back as negative.

Wow

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 02-21-2005 19:44

?! how could it be negative. All the numbers are squared.
Are you sure the symbol ^ is not interpreted as the "exclusive or" ?
Try with a dull syntax :

code:
testDist=(dR-R)*(dR-R)/(aa*aa)+(dG-G)*(dG-G)/(bb*b)+(dB-B)*(dB-B)/(cc*cc)



warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 02-21-2005 19:58

Odd.

I double-checked the docs and ^ is indeed XOR.
This would explain some of the other code that I've looked at.
Damn you, BASIC.

However, it seems to be working just fine with ^ like I have it.
I put it through some serious tests and it came up spades.

Maybe XOR is an undocumented short-cut for squaring.
Heh.

I don't get it.
Time to take a break for a few hours.

« BackwardsOnwards »

Show Forum Drop Down Menu