MATLAB Answers

how to check if a point is inside an rotated ellipsoid?

55 views (last 30 days)
i made a ellipsoid with this function [X,Y,Z] = ellipsoid(xc,yc,zc,xr,yr,zr) and with function (rotate) i rotated with certain angel.
after rotation the ellipsoid , how can we check if a given point with its coordinante(x,y,z) is inside of ellipsoid.
If ellipsoid is oriented in main axes (not rotated) we can use the equation from ellipsoid also :
(x/a)2 + (y/b)2 + (z/c)2 < 1 point is inside ellipsoid
(x/a)2 + (y/b)2 + (z/c)2 > 1 point is not inside ellipsoid
but how can we check if the point is inside when ellipsoid is rotated? in this case are all point of ellipsoid rotated and we can not use upper equation anymore , right?


Sign in to comment.

Accepted Answer

David Goodmanson
David Goodmanson on 19 Dec 2020
Edited: David Goodmanson on 19 Dec 2020
Hi Amin,
Since it appears that you know the rotation matrix, you can rotate the point p in question in the opposite direction to how you rotated the ellipsoid, keeping in mind that you have to rotate about the same rotation axis as before. For point p, the coordinates (x,y,z) --> (x1,y1,z1). Then use the new coordinates in the equations that you show above. Except that the ellipse is centered at xc,yc,zc so correct equation is actually
(x-xc)^2 (y-yc)^2 (z-zc)^2
-------- + -------- + -------- <1 inside or >1 outside
xr^2 yr^2 zr^2


Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by