Class 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 that r1 > 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 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 https://en.wikipedia.org/wiki/Torus#Geometry
    See Also:
    Torus
    • 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 radius r1 and a partial cross section circle with radius r2.
      TorusSector​(double r1, double r2, double theta1, double theta2, int n, int k)
      Create a partial torus with a partial circle of revolution with radius r1 and a cross section circle (circle of longitude) with radius r2.
    • Field Detail

      • r1

        public final double r1
      • r2

        public final double r2
      • n

        public final int n
      • k

        public final int k
    • 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 radius r1 and a cross section circle (circle of longitude) with radius r2.

        If theta1 > 0 or theta2 < 2*PI, then the (partial) circle of revolution is the circular sector from angle theta1 to angle theta2. In other words, the (partial) circles of latitude in the model extend from angle theta1 to angle theta2.

        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 have k-1 line segments. If there are n (partial) circles of latitude, then each circle of longitude will have n 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 revolution
        r2 - radius of the cross section circle (circle of longitude)
        theta1 - beginning longitude angle for the circle of revolution
        theta2 - ending longitude angle for the circle of revolution
        n - number of circles of latitude
        k - number of circles of longitude
        Throws:
        IllegalArgumentException - if n is less than 4
        IllegalArgumentException - if k 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 radius r1 and a partial cross section circle with radius r2.

        If phi1 > 0 or phi2 < 2*PI, then the (partial) cross section circle is the circular sector from angle phi1 to angle phi2. In other words, the (partial) circles of longitude in the model extend from angle phi1 to angle phi2.

        If theta1 > 0 or theta2 < 2*PI, then the (partial) circle of revolution is the circular sector from angle theta1 to angle theta2. In other words, the (partial) circles of latitude in the model extend from angle theta1 to angle theta2.

        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 have k-1 line segments. If there are n (partial) circles of latitude, then each circle of longitude will have n-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 revolution
        r2 - radius of the cross section circle (circle of longitude)
        theta1 - beginning longitude angle for the circle of revolution
        theta2 - ending longitude angle for the circle of revolution
        phi1 - beginning latitude angle for the cross section circle
        phi2 - ending latitude angle for the cross section circle
        n - number of circles of latitude
        k - number of circles of longitude
        Throws:
        IllegalArgumentException - if n is less than 4
        IllegalArgumentException - if k is less than 4
    • Method Detail

      • remake

        public TorusSector remake​(int n,
                                  int k)
        Description copied from interface: MeshMaker
        Build an instance of the Model with new values for the number of lines of latitude and longitude while keeping all the other model parameters the same.
        Specified by:
        remake in interface MeshMaker
        Parameters:
        n - number of lines of latitude for the returned Model
        k - number of lines of longitude for the returned Model
        Returns:
        a new instance of the Model with the updated parameters