Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by S_Darkwell · Dec 11, 2016 at 04:06 PM · mathsphereradiustrigonometryellipse

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.

alt text

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! :)

Thank you and be well!

-S.

example.png (81.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Dec 11, 2016 at 05:25 PM

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Dec 11, 2016 at 05:50 PM 0
Share

$$anonymous$$eep in $$anonymous$$d that when you actually used the default sphere that the radius is actually 0.5 and not 1. So when you scale the gameobject to ( 3, 4, 2 ) the actual radii would be (1.5, 2, 1). Also if you actually use a stretched default sphere you could simply do:

 dir = (transform.worldToLocal$$anonymous$$atrix * dir).normalized*0.5f;
 return transform.localToWorld$$anonymous$$atrix *dir;

Note: TransformDirection / InverseTransformDirection does not take the scale into account so they can't be used. However using the world to local and local to world matrices should work just fine since the vector3 is implicitly converted into a vector4 and w defaults to 0, so it doesn't apply the translation but only rotation and scale.

avatar image S_Darkwell · Dec 11, 2016 at 05:57 PM 0
Share

Both of these solutions do in fact project a point on a sphereoid (with the first example merely requiring the additional conversion from scale to radius).

Technically my question was how to obtain the radius, so the answer would be to take either solution and wrap the return with ().magnitude;.

avatar image Bunny83 S_Darkwell · Dec 11, 2016 at 06:25 PM 1
Share

Uhm, that should be pretty obvious ^^. In most cases the actual vector to the intersection point is much more useful than just the length of radius at that point. Technically that vector is the radius (it's the line that connects the center with the perimeter / hull).

avatar image S_Darkwell Bunny83 · Dec 11, 2016 at 06:38 PM 0
Share

Understood! Just wasn't certain how explicit to be for future readers.

Thank you so much for your help! Your solution(s) are elegant, and they certainly saved me many more hours of pondering. :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

84 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Math Q: Compensating for ball radius on a reflection. 2 Answers

Creating a parabola line in 3D Space 1 Answer

Sphere coords, radiating from centre. 0 Answers

How to properly offset a Handles.DrawSolidArc by an angle in different axis? 2 Answers

Increase the radius of Unity's primitive sphere? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges