Class Torus
- java.lang.Object
-
- renderer.scene.Model
-
- renderer.models_L.Torus
-
- All Implemented Interfaces:
MeshMaker
public class Torus extends Model implements MeshMaker
Create a wireframe model of a torus.See https://en.wikipedia.org/wiki/Torus
This torus is the surface of revolution generated by revolving the circle in the xy-plane with radius
r2
and center(r1,0,0)
around the y-axis. We are assuming thatr1 > r2
.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:
TorusSector
-
-
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 Torus()
Create a torus with a circle of revolution with radius 3/4 and a cross section circle (circle of longitude) with radius 1/4.Torus(double r1, double r2)
Create a torus with a circle of revolution with radiusr1
and a cross section circle (circle of longitude) with radiusr2
.Torus(double r1, double r2, int n, int k)
Create a torus with a 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()
Torus
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
-
Torus
public Torus()
Create a torus with a circle of revolution with radius 3/4 and a cross section circle (circle of longitude) with radius 1/4.
-
Torus
public Torus(double r1, double r2)
Create a torus with a circle of revolution with radiusr1
and a cross section circle (circle of longitude) with radiusr2
.- Parameters:
r1
- radius of the circle of revolutionr2
- radius of the cross section circle (circle of longitude)
-
Torus
public Torus(double r1, double r2, int n, int k)
Create a torus with a circle of revolution with radiusr1
and a cross section circle (circle of longitude) with radiusr2
.The last two parameters determine the number of circles of longitude and the number of circles of latitude in the model.
If there are
n
circles of latitude, then each circle of longitude will haven
line segments. If there arek
circles of longitude, then each circle of latitude will havek
line segments.There must be at least three 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)n
- number of circles of latitudek
- number of circles of longitude- Throws:
IllegalArgumentException
- ifn
is less than 3IllegalArgumentException
- ifk
is less than 3
-
-
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
-
-