public class Torus extends Model
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 that r1 > 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 parameter 0 <= phi <= 2*PI
.
x(phi) = r1 + r2 * sin(phi)
y(phi) = r2 * cos(phi)
z(phi) = 0
Here is the 3D rotation matrix that rotates around the y-axis
by theta
radians with 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 circle parameterization,
we get a parameterization of the torus.
[ 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
http://en.wikipedia.org/wiki/Torus#GeometryTorusSector
lineSegmentList, vertexList, visible
Constructor and 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 radius
r1
and a cross section circle (circle of longitude) with radius
r2 . |
Torus(double r1,
double r2,
int n,
int k)
Create a torus with a circle of revolution with radius
r1
and a cross section circle (circle of longitude) with radius
r2 . |
addLineSegment, addLineSegment, addVertex, setColor, setColorRandom, setRandomColors, setRandomLineSegmentColors, toString
public Torus()
public Torus(double r1, double r2)
r1
and a cross section circle (circle of longitude) with radius
r2
.r1
- radius of the circle of revolutionr2
- radius of the cross section circle (circle of longitude)public Torus(double r1, double r2, int n, int k)
r1
and a cross section circle (circle of longitude) with radius
r2
.
The last two parameters determine the number of circles of longitude and the number of circles of latitude in the model.
Notice that if there are n
circles of latitude, then each
circle of longitude will have n
line segments. If there
are k
circles of longitude, then each circle of latitude
will have k
line segments.
There must be at least three circles of longitude and at least three circles of latitude.
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