Class TorusSector
- java.lang.Object
-
- renderer.scene.Model
-
- renderer.models_L.TorusSector
-
- All Implemented Interfaces:
MeshMaker
public class TorusSector extends Model implements MeshMaker
Create a wireframe model of a partial torus.See https://en.wikipedia.org/wiki/Torus
This partial torus is the surface of revolution generated by revolving a sector of the circle in the xy-plane with radius
r2
and center(r1,0,0)
part way around the y-axis. We are assuming thatr1 > r2
.The whole torus is the surface of revolution generated by revolving the whole circle in the xy-plane with radius
r2
and center(r1,0,0)
all the way around the y-axis.Here are parametric equations for the circle in the xy-plane with radius
r2
and center(r1,0,0)
and parameterized starting from the top, with parameter0 <= phi <= 2*PI
.
Here is the 3D rotation matrix that rotates around the y-axis byx(phi) = r1 + r2 * sin(phi) y(phi) = r2 * cos(phi) z(phi) = 0
theta
radians with0 <= theta <= 2*PI
.
If we multiply the rotation matrix with the circle parameterization, we get a parameterization of the torus.[ cos(theta) 0 sin(theta)] [ 0 1 0 ] [-sin(theta) 0 cos(theta)]
See https://en.wikipedia.org/wiki/Torus#Geometry[ cos(theta) 0 sin(theta)] [r1 + r2 * sin(phi)] [ 0 1 0 ] * [ r2 * cos(phi)] [-sin(theta) 0 cos(theta)] [ 0 ] = ( r1*cos(theta) + r2*cos(theta)*sin(phi). r2*cos(phi), -r1*sin(theta) - r2*sin(theta)*sin(phi) ) = ( (r1 + r2*sin(phi)) * cos(theta), r2*cos(phi), -(r1 + r2*sin(phi)) * sin(theta) )
- See Also:
Torus
-
-
Field Summary
Fields Modifier and Type Field Description int
k
int
n
double
r1
double
r2
-
Fields inherited from class renderer.scene.Model
colorList, name, primitiveList, vertexList, visible
-
-
Constructor Summary
Constructors Constructor Description TorusSector()
Create a partial torus with half the circle of revolution with radius 3/4 and a cross section that is half the circle of longitude with radius 1/4.TorusSector(double r1, double r2, double theta1, double theta2, double phi1, double phi2, int n, int k)
Create a partial torus with a partial circle of revolution with radiusr1
and a partial cross section circle with radiusr2
.TorusSector(double r1, double r2, double theta1, double theta2, int n, int k)
Create a partial torus with a partial circle of revolution with radiusr1
and a cross section circle (circle of longitude) with radiusr2
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getHorzCount()
int
getVertCount()
TorusSector
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
-
TorusSector
public TorusSector()
Create a partial torus with half the circle of revolution with radius 3/4 and a cross section that is half the circle of longitude with radius 1/4.
-
TorusSector
public TorusSector(double r1, double r2, double theta1, double theta2, int n, int k)
Create a partial torus with a partial circle of revolution with radiusr1
and a cross section circle (circle of longitude) with radiusr2
.If
theta1 > 0
ortheta2 < 2*PI
, then the (partial) circle of revolution is the circular sector from angletheta1
to angletheta2
. In other words, the (partial) circles of latitude in the model extend from angletheta1
to angletheta2
.The last two parameters determine the number of circles of longitude and the number of (partial) circles of latitude in the model.
If there are
k
circles of longitude, then each (partial) circle of latitude will havek-1
line segments. If there aren
(partial) circles of latitude, then each circle of longitude will haven
line segments.There must be at least four circles of longitude and at least three circles of latitude.
- Parameters:
r1
- radius of the circle of revolutionr2
- radius of the cross section circle (circle of longitude)theta1
- beginning longitude angle for the circle of revolutiontheta2
- ending longitude angle for the circle of revolutionn
- number of circles of latitudek
- number of circles of longitude- Throws:
IllegalArgumentException
- ifn
is less than 4IllegalArgumentException
- ifk
is less than 4
-
TorusSector
public TorusSector(double r1, double r2, double theta1, double theta2, double phi1, double phi2, int n, int k)
Create a partial torus with a partial circle of revolution with radiusr1
and a partial cross section circle with radiusr2
.If
phi1 > 0
orphi2 < 2*PI
, then the (partial) cross section circle is the circular sector from anglephi1
to anglephi2
. In other words, the (partial) circles of longitude in the model extend from anglephi1
to anglephi2
.If
theta1 > 0
ortheta2 < 2*PI
, then the (partial) circle of revolution is the circular sector from angletheta1
to angletheta2
. In other words, the (partial) circles of latitude in the model extend from angletheta1
to angletheta2
.The last two parameters determine the number of (partial) circles of longitude and the number of (partial) circles of latitude in the model.
If there are
k
circles of longitude, then each (partial) circle of latitude will havek-1
line segments. If there aren
(partial) circles of latitude, then each circle of longitude will haven-1
line segments.There must be at least four circles of longitude and at least four circles of latitude.
- Parameters:
r1
- radius of the circle of revolutionr2
- radius of the cross section circle (circle of longitude)theta1
- beginning longitude angle for the circle of revolutiontheta2
- ending longitude angle for the circle of revolutionphi1
- beginning latitude angle for the cross section circlephi2
- ending latitude angle for the cross section circlen
- number of circles of latitudek
- number of circles of longitude- Throws:
IllegalArgumentException
- ifn
is less than 4IllegalArgumentException
- 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 TorusSector 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.
-
-