Class SphereSector

  • All Implemented Interfaces:
    MeshMaker

    public class SphereSector
    extends Model
    implements MeshMaker
    Create a wireframe model of a partial sphere centered at the origin

    See https://en.wikipedia.org/wiki/Sphere

    By a partial sphere we mean cutting a hole in the sphere around either the north or the south pole (that is, removing a spherical cap from either the top or bottom of the sphere) and also cutting from the sphere a spherical wedge between two lines of longitude.

    Notice that we can use this model to both model a spherical wedge and to model a sphere with a spherical wedge removed from it.

    Similarly, we can use this model to both model a spherical cap and to model a sphere with a spherical cap removed from it.

    See https://en.wikipedia.org/wiki/Spherical_cap

    See https://en.wikipedia.org/wiki/Spherical_segment

    See https://en.wikipedia.org/wiki/Spherical_wedge

    The whole sphere of radius r is the surface of revolution generated by revolving the right half-circle in the xy-plane with radius r and center (0,0,0) all the way around the y-axis.

    Here are parametric equations for the right half-circle in the xy-plane with radius r and center (0,0,0), parameterized from the top down.

    
          x(phi) = r * sin(phi)  \
          y(phi) = r * cos(phi)   |-  0 <= phi <= PI
          z(phi) = 0             /
       
    Here is the 3D rotation matrix that rotates around the y-axis by theta radians, 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 half-circle parameterization, we get a parameterization of the sphere.
    
          [ cos(theta)   0   sin(theta)]   [r * sin(phi)]
          [     0        1       0     ] * [r * cos(phi)]
          [-sin(theta)   0   cos(theta)]   [     0      ]
    
          = ( r * sin(phi) * cos(theta).    \
              r * cos(phi),                  |- 0<=theta<=2*PI,  0<=phi<=PI
             -r * sin(phi) * sin(theta) )   /
       
    See https://en.wikipedia.org/wiki/Sphere#Equations_in_three-dimensional_space
    See Also:
    Sphere, CircleSector, DiskSector, RingSector, ConeSector, CylinderSector, TorusSector
    • Field Detail

      • r

        public final double r
      • theta1

        public final double theta1
      • theta2

        public final double theta2
      • phi1

        public final double phi1
      • phi2

        public final double phi2
      • n

        public final int n
      • k

        public final int k
    • Constructor Detail

      • SphereSector

        public SphereSector()
        Create half of a sphere of radius 1 centered at the origin.
      • SphereSector

        public SphereSector​(double r,
                            double theta1,
                            double theta2,
                            int n,
                            int k)
        Create a part of the sphere of radius r centered at the origin.

        If theta1 > 0 and theta1 < theta2 < 2*PI, then a spherical wedge is removed from the model. 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 half circles of longitude and the number of (partial) circles of latitude in the model.

        If there are k half circles of longitude, then each (partial) circle of latitude will have k-1 line segments. If there are n circles of latitude, then each half circle of longitude will have n+1 line segments.

        There must be at least four half circles of longitude and at least one circle of latitude.

        Parameters:
        r - radius of the sphere
        theta1 - beginning longitude angle (in radians) of the spherical wedge
        theta2 - ending longitude angle (in radians) of the spherical wedge
        n - number of circles of latitude
        k - number of lines of longitude, not counting the edges of a spherical wedge
        Throws:
        IllegalArgumentException - if n is less than 3
        IllegalArgumentException - if k is less than 4
      • SphereSector

        public SphereSector​(double r,
                            double theta1,
                            double theta2,
                            double phi1,
                            double phi2,
                            int n,
                            int k)
        Create a part of the sphere of radius r centered at the origin.

        If phi1 > 0, then there is hole in the sphere around its north pole. Similarly, if phi2 < PI, then there is a hole in the sphere around its south pole. In other words, in spherical coordinates, lines of longitude in the model extend from angle phi1 to angle phi2.

        If theta1 > 0 and theta1 < theta2 < 2*PI, then a spherical wedge is removed from the model. 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 lines of longitude and the number of (partial) circles of latitude in the model.

        If there are k lines of longitude, then each (partial) circle of latitude will have k-1 line segments. If there are n circles of latitude (including the edges of the removed spherical caps), then each line of longitude will have n-1 line segments.

        There must be at least four lines of longitude and at least three circles of latitude.

        Parameters:
        r - radius of the sphere
        theta1 - beginning longitude angle (in radians) of the spherical wedge
        theta2 - ending longitude angle (in radians) of the spherical wedge
        phi1 - beginning latitude angle (in radians) of the spherical segment
        phi2 - ending latitude angle (in radians) of the spherical segment
        n - number of circles of latitude, not counting the edges of a spherical segment
        k - number of lines of longitude, not counting one edge of a spherical wedge
        Throws:
        IllegalArgumentException - if n is less than 3
        IllegalArgumentException - if k is less than 4
    • Method Detail

      • remake

        public SphereSector 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