Radius of a Non-Uniform Sphereoid/Ellipsoid at a Given Surface Point?

Hello!

I have spent a few days mulling over this problem, but have made little progress.
Unfortunately, spherical trigonometry is not my strong point.
I hope you can help!

What I require is a function that given an input vector, will return the radius of a sphereoid at the point where the vector would intercept the spheroid’s surface, assuming assuming that the given vector extends from the sphereoid’s center.

I’ve explored numerous equations, but most only handle elliptical radii (and I struggle to combine the third direction), or give me results that fluctuate as the input vector is modified.

Any assistance is greatly appreciated! :slight_smile:

Thank you and be well!

-S.

Well, the easiest way is to treat the ellipsoid as a stretched spherical space. So all you have to do is un-stretching your vector, normalize it and stretch it back

// untested
Vector3 ProjectOnEllipsoid(Vector3 aEllipsoidSize, Vector3 aDir)
{
    aDir.x /= aEllipsoidSize.x;
    aDir.y /= aEllipsoidSize.y;
    aDir.z /= aEllipsoidSize.z;
    aDir.Normalize();
    return Vector3.Scale(aDir, aEllipsoidSize);
}

Unfortunately there’s no easy way to divide two vectors component-wise in one operation so you have to do it manually.