Class SphereSector
- java.lang.Object
-
- renderer.scene.Model
-
- renderer.models_L.SphereSector
-
- All Implemented Interfaces:
MeshMaker
public class SphereSector extends Model implements MeshMaker
Create a wireframe model of a partial sphere centered at the originSee https://en.wikipedia.org/wiki/Sphere
By a partial sphere we mean cutting a hole in the sphere around either the north or the south pole (that is, removing a spherical cap from either the top or bottom of the sphere) and also cutting from the sphere a spherical wedge between two lines of longitude.
Notice that we can use this model to both model a spherical wedge and to model a sphere with a spherical wedge removed from it.
Similarly, we can use this model to both model a spherical cap and to model a sphere with a spherical cap removed from it.
See https://en.wikipedia.org/wiki/Spherical_cap
See https://en.wikipedia.org/wiki/Spherical_segment
See https://en.wikipedia.org/wiki/Spherical_wedge
The whole sphere of radius
r
is the surface of revolution generated by revolving the right half-circle in the xy-plane with radiusr
and center(0,0,0)
all the way 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.
Here is the 3D rotation matrix that rotates around the y-axis byx(phi) = r * sin(phi) \ y(phi) = r * cos(phi) |- 0 <= phi <= PI z(phi) = 0 /
theta
radians,0 <= theta <= 2*PI
If we multiply the rotation matrix with the half-circle parameterization, we get a parameterization of the sphere.[ cos(theta) 0 sin(theta)] [ 0 1 0 ] [-sin(theta) 0 cos(theta)]
See https://en.wikipedia.org/wiki/Sphere#Equations_in_three-dimensional_space[ 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 Also:
Sphere
,CircleSector
,DiskSector
,RingSector
,ConeSector
,CylinderSector
,TorusSector
-
-
Constructor Summary
Constructors Constructor Description SphereSector()
Create half of a sphere of radius 1 centered at the origin.SphereSector(double r, double theta1, double theta2, double phi1, double phi2, int n, int k)
Create a part of the sphere of radius r centered at the origin.SphereSector(double r, double theta1, double theta2, int n, int k)
Create a part of the sphere of radius r centered at the origin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getHorzCount()
int
getVertCount()
SphereSector
remake(int n, int k)
Build an instance of theModel
with new values for the number of lines of latitude and longitude while keeping all the other model parameters the same.-
Methods inherited from class renderer.scene.Model
addColor, addPrimitive, addVertex, getPrimitive, toString
-
-
-
-
Constructor Detail
-
SphereSector
public SphereSector()
Create half of a sphere of radius 1 centered at the origin.
-
SphereSector
public SphereSector(double r, double theta1, double theta2, int n, int k)
Create a part of the sphere of radius r centered at the origin.If
theta1 > 0
andtheta1 < theta2 < 2*PI
, then a spherical wedge is removed from the model. In other words, the (partial) circles of latitude in the model extend from angletheta1
to angletheta2
.The last two parameters determine the number of half circles of longitude and the number of (partial) circles of latitude in the model.
If there are
k
half circles of longitude, then each (partial) circle of latitude will havek-1
line segments. If there aren
circles of latitude, then each half circle of longitude will haven+1
line segments.There must be at least four half circles of longitude and at least one circle of latitude.
- Parameters:
r
- radius of the spheretheta1
- beginning longitude angle (in radians) of the spherical wedgetheta2
- ending longitude angle (in radians) of the spherical wedgen
- number of circles of latitudek
- number of lines of longitude, not counting the edges of a spherical wedge- Throws:
IllegalArgumentException
- ifn
is less than 3IllegalArgumentException
- ifk
is less than 4
-
SphereSector
public SphereSector(double r, double theta1, double theta2, double phi1, double phi2, int n, int k)
Create a part of the sphere of radius r centered at the origin.If
phi1 > 0
, then there is hole in the sphere around its north pole. Similarly, ifphi2 < PI
, then there is a hole in the sphere around its south pole. In other words, in spherical coordinates, lines of longitude in the model extend from anglephi1
to anglephi2
.If
theta1 > 0
andtheta1 < theta2 < 2*PI
, then a spherical wedge is removed from the model. In other words, the (partial) circles of latitude in the model extend from angletheta1
to angletheta2
.The last two parameters determine the number of lines of longitude and the number of (partial) circles of latitude in the model.
If there are
k
lines of longitude, then each (partial) circle of latitude will havek-1
line segments. If there aren
circles of latitude (including the edges of the removed spherical caps), then each line of longitude will haven-1
line segments.There must be at least four lines of longitude and at least three circles of latitude.
- Parameters:
r
- radius of the spheretheta1
- beginning longitude angle (in radians) of the spherical wedgetheta2
- ending longitude angle (in radians) of the spherical wedgephi1
- beginning latitude angle (in radians) of the spherical segmentphi2
- ending latitude angle (in radians) of the spherical segmentn
- number of circles of latitude, not counting the edges of a spherical segmentk
- number of lines of longitude, not counting one edge of a spherical wedge- Throws:
IllegalArgumentException
- ifn
is less than 3IllegalArgumentException
- ifk
is less than 4
-
-
Method Detail
-
getHorzCount
public int getHorzCount()
- Specified by:
getHorzCount
in interfaceMeshMaker
- Returns:
- the number of lines of latitude that the
Model
contains
-
getVertCount
public int getVertCount()
- Specified by:
getVertCount
in interfaceMeshMaker
- Returns:
- the number of lines of longitude that the
Model
contains
-
remake
public SphereSector remake(int n, int k)
Description copied from interface:MeshMaker
Build an instance of theModel
with new values for the number of lines of latitude and longitude while keeping all the other model parameters the same.
-
-