public class Sphere extends Model
See https://en.wikipedia.org/wiki/Sphere
A sphere of radius r
is the surface of revolution generated by
revolving a half-circle in the xy-plane with radius r
and center
(0,0,0)
around the y-axis.
Here are parametric equations for the right half-circle in the xy-plane with
radius r
and center (0,0,0)
, parameterized from the top down.
x(phi) = r * sin(phi) \
y(phi) = r * cos(phi) |- 0 <= phi <= PI
z(phi) = 0 /
Here is the 3D rotation matrix that rotates around the y-axis
by theta
radians, 0 <= theta <= 2*PI
[ cos(theta) 0 sin(theta)]
[ 0 1 0 ]
[-sin(theta) 0 cos(theta)]
If we multiply the rotation matrix with the half-circle
parameterization, we get a parameterization of the sphere.
[ cos(theta) 0 sin(theta)] [r * sin(phi)]
[ 0 1 0 ] * [r * cos(phi)]
[-sin(theta) 0 cos(theta)] [ 0 ]
= ( r * sin(phi) * cos(theta). \
r * cos(phi), |- 0<=theta<=2*PI, 0<=phi<=PI
-r * sin(phi) * sin(theta) ) /
See
https://en.wikipedia.org/wiki/Sphere#Equations_in_three-dimensional_spaceSphereSector
hidden, lineSegmentList
public Sphere()
public Sphere(double r)
r
centered at the origin.r
- radius of the spherepublic Sphere(double r, int n, int k)
r
centered at the origin.
The last two parameters determine the number of half circles of longitude and the number of circles of latitude in the model.
Notice that if there are k
half circles of longitude,
then each circle of latitude will have k
line segments.
If there are n
circles of latitude, then each half circle
of longitude will have n+1
line segments.
There must be at least three half circles of longitude and at least one circle of latitude.
r
- radius of the spheren
- number of circles of latitudek
- number of half circles of longitude