com.io7m.r2.meshes.defaults

## Class R2UnitSphere

- java.lang.Object
- - com.io7m.r2.meshes.defaults.R2UnitSphere

- All Implemented Interfaces:
    com.io7m.jcanephora.core.JCGLResourceSizedType, com.io7m.jcanephora.core.JCGLResourceUsableType, R2DeletableType, R2UnitSphereType, R2UnitSphereUsableType

      public final class R2UnitSphere
      extends Object
      implements R2UnitSphereType

  The default implementation of the `R2UnitSphereType` interface.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.io7m.jcanephora.core.JCGLArrayObjectUsableType` | `arrayObject()`
    `void` | `delete(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g)` Delete the current object.
    `static double` | `getCircleArea(double r)` Calculate the area of a circle with radius `r`.
    `com.io7m.junsigned.ranges.UnsignedRangeInclusiveL` | `getRange()`
    `static double` | `getUVSphereApproximationArea(double r, int s)` Calculate the area of an approximation of a circle with radius `r` constructed with `s` line segments.
    `static double` | `getUVSphereApproximationScaleFactor(double r, int s)` Calculate the scale factor required to completely contain a circle of radius `r` inside an approximation with radius `r` constructed with `s` line segments.
    `static double` | `getUVSphereApproximationTriangleArea(double r, int s)` Calculate the area of one of the triangles that make up an approximation of a circle with radius `r` constructed with `s` line segments.
    `static double` | `getUVSphereTriangleInteriorAngle(int s)` A UV sphere approximates a real sphere by using a fixed number of vertical segments.
    `boolean` | `isDeleted()`
    `static R2UnitSphereType` | `newUnitSphere8(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g)` Construct a new `8` segment unit sphere.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### newUnitSphere8

          public static R2UnitSphereType newUnitSphere8(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g)

      Construct a new `8` segment unit sphere.
      Parameters:
        `g` - An OpenGL interface
      Returns:
        A new unit sphere

    - #### getUVSphereTriangleInteriorAngle

          public static double getUVSphereTriangleInteriorAngle(int s)

      A UV sphere approximates a real sphere by using a fixed number of vertical segments. When using `8` segments, for example, the sphere looks like an octagon when viewed from above. This function returns the interior angle, in radians, of one of the triangles that make up the shape.

      The following always holds: `2 * π = n * getUVSphereTriangleInteriorAngle(n)`

      Parameters:
        `s` - The number of segments
      Returns:
        The interior angle of one of the resulting triangles

    - #### getUVSphereApproximationTriangleArea

          public static double getUVSphereApproximationTriangleArea(double r,
                                                                    int s)

      Calculate the area of one of the triangles that make up an approximation of a circle with radius `r` constructed with `s` line segments.

      Parameters:
        `r` - The radius
        `s` - The number of segments in the approximation
      Returns:
        The approximation area

    - #### getUVSphereApproximationScaleFactor

          public static double getUVSphereApproximationScaleFactor(double r,
                                                                   int s)

      Calculate the scale factor required to completely contain a circle of radius `r` inside an approximation with radius `r` constructed with `s` line segments.

      Parameters:
        `r` - The radius
        `s` - The number of segments in the approximation
      Returns:
        The approximation area

    - #### getUVSphereApproximationArea

          public static double getUVSphereApproximationArea(double r,
                                                            int s)

      Calculate the area of an approximation of a circle with radius `r` constructed with `s` line segments.

      Parameters:
        `r` - The radius
        `s` - The number of segments in the approximation
      Returns:
        The approximation area

    - #### getCircleArea

          public static double getCircleArea(double r)

      Calculate the area of a circle with radius `r`.

      Parameters:
        `r` - The radius
      Returns:
        The circle area

    - #### delete

          public void delete(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g)
                      throws R2Exception

      Description copied from interface: `R2DeletableType`
      Delete the current object.
      Specified by:
        `delete` in interface `R2DeletableType`
      Parameters:
        `g` - An OpenGL interface
      Throws:
        `R2Exception` - On errors

    - #### arrayObject

          public com.io7m.jcanephora.core.JCGLArrayObjectUsableType arrayObject()

      Specified by:
        `arrayObject` in interface `R2UnitSphereUsableType`
      Returns:
        The array object for the sphere

    - #### getRange

          public com.io7m.junsigned.ranges.UnsignedRangeInclusiveL getRange()

      Specified by:
        `getRange` in interface `com.io7m.jcanephora.core.JCGLResourceSizedType`

    - #### isDeleted

          public boolean isDeleted()

      Specified by:
        `isDeleted` in interface `com.io7m.jcanephora.core.JCGLResourceUsableType`

Copyright © 2016 <code@io7m.com> http://io7m.com