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
r2and 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
r2and 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) = 0thetaradians 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 intkintndoubler1doubler2-
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 radiusr1and 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 radiusr1and a cross section circle (circle of longitude) with radiusr2.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetHorzCount()intgetVertCount()Torusremake(int n, int k)Build an instance of theModelwith 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 radiusr1and 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 radiusr1and 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
ncircles of latitude, then each circle of longitude will havenline segments. If there arekcircles of longitude, then each circle of latitude will havekline 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- ifnis less than 3IllegalArgumentException- ifkis less than 3
-
-
Method Detail
-
getHorzCount
public int getHorzCount()
- Specified by:
getHorzCountin interfaceMeshMaker- Returns:
- the number of lines of latitude that the
Modelcontains
-
getVertCount
public int getVertCount()
- Specified by:
getVertCountin interfaceMeshMaker- Returns:
- the number of lines of longitude that the
Modelcontains
-
-