- Home /
How to get a sphere surface with a solid angle through script?
Hi, as a newbie in Unity, I have been trying to get a surface, or a shell of a sphere. The following picture may be a good example of what I want.
The area A is exactly what I need, as a Gameobject in Unity. I hope that I can change the Omega programmatically (the value of the Omega is depended on the player).
Any suggestion will be appreciated.
Noting builtin like that exists. I suspect you will want to create a "$$anonymous$$esh", programmatically, so you can recompute it when Omega changes. https://docs.unity3d.com/ScriptReference/$$anonymous$$esh.html Lots of good stuff out there on creating a mesh at runtime, so I won't go into detail here.
I am learning how to implement a mesh. Thanks for pointing out the direction :)
So you need the Area (a number) or an object that represents that slice?
Answer by Kishotta · Oct 06, 2017 at 09:43 PM
What you're looking for is called a Spherical Cap. Using only the information you've given, it can be calculated with the formula: Α=2πr2(1-cosθ) where θ is the Ω in your original image.
As for creating an actual mesh out of this, you can use the Area calculated above to determine the number of bands on a Radial mesh. To close it up and make a proper "wedge" of your sphere, just link the outer vertices to the center of the sphere. I'm not sure how to make this work for the area OUTSIDE the cap (the rest of the sphere) but hopefully it helps some.