Determing if a point is inside an ellipsoid

How can you determine if a given set of points is inside an off center rotated ellipsoid?

 Accepted Answer

the point (x,y,z) will be inside the ellipsoid when
(x-xo)^2/a + (y-yo)^2/b +(z-zo)^2/c < 1
it will be outside the ellipsoid when
(x-xo)^2/a + (y-yo)^2/b +(z-zo)^2/c > 1

7 Comments

How do i take the rotation into account?
The equation in matrix form for a rotated ellipse is
x'*R'*diag(1./[a,b])*R*x<=1
where R is a rotation matrix.
Omair, I don't understand. You must have the ellipsoid equation already. If you don't then what is there to check your points against? If you just have points and no equation at all, then of course you can find any arbitrary huge ellipsoid that will contain them all, but that's not useful. I'm not sure why you asked about rotation.
I have training data set to which I am trying to fit an ellipsoid. This data is distributed along the x=y=z line in 3 dimensions. I know my rotation matrix and i know my center of the ellipsoid. I want to check the goodness of fit by varying different parameters of the ellipsoid. My evaluation criteria for the goodness of the fit is true positives and false positives. I need to find how many of my sample training points lie inside the ellipsoid and how many of my disturbance points lie inside the ellipsoid.
One thing i tried was to apply the inverse of the rotation matrix to my data points and then check if the points lie inside the ellipsoid or not using the above given equation. Does that make sense?
You might try the FAQ though that might be for fitting an ellipsoid shell rather than solid - I don't know. How did you discover your rotation matrix if you don't even have the equation of the ellipse yet??? How are you determining the angle and length of the axes of the ellipsoid? And if you have those, then you have the equation.
I know that my data is distributed along the x=y=z line in the [0,300] for all three variables. The rotation matrix i derived using this information.
If anybody else stumbles upon this and has trouble with the equation not working:
((x-xo)/a)^2 + ((y-yo)/b)^2 +((z-zo)/c)^2 < 1
Taking the whole fractions squared instead of just the distance from the point to the ellipsoid center worked for me.

Sign in to comment.

More Answers (0)

Tags

Asked:

on 25 Nov 2013

Commented:

on 7 Oct 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!