Class Ring

java.lang.Object
com.ardor3d.math.Ring
All Implemented Interfaces:
Poolable, ReadOnlyRing, Savable, Externalizable, Serializable, Cloneable

public class Ring extends Object implements Cloneable, Savable, Externalizable, ReadOnlyRing, Poolable
Ring defines a flat ring or disk within three dimensional space that is specified via the ring's center point, an up vector, an inner radius, and an outer radius.
See Also:
  • Constructor Details

    • Ring

      public Ring()
      Constructor creates a new Ring lying on the XZ plane, centered at the origin, with an inner radius of zero and an outer radius of one (a unit disk).
    • Ring

      public Ring(ReadOnlyRing source)
      Copy constructor.
      Parameters:
      source - the ring to copy from.
    • Ring

      public Ring(ReadOnlyVector3 center, ReadOnlyVector3 up, double innerRadius, double outerRadius)
      Constructor creates a new Ring with defined center point, up vector, and inner and outer radii.
      Parameters:
      center - the center of the ring.
      up - the unit up vector defining the ring's orientation.
      innerRadius - the ring's inner radius.
      outerRadius - the ring's outer radius.
  • Method Details

    • set

      public Ring set(ReadOnlyRing source)
      Copy the value of the given source Ring into this Ring.
      Parameters:
      source - the source of the data to copy.
      Returns:
      this ring for chaining
      Throws:
      NullPointerException - if source is null.
    • getCenter

      public ReadOnlyVector3 getCenter()
      getCenter returns the center of the ring.
      Specified by:
      getCenter in interface ReadOnlyRing
      Returns:
      the center of the ring.
    • setCenter

      public void setCenter(ReadOnlyVector3 center)
      setCenter sets the center of the ring.
      Parameters:
      center - the center of the ring.
    • getUp

      public ReadOnlyVector3 getUp()
      getUp returns the ring's up vector.
      Specified by:
      getUp in interface ReadOnlyRing
      Returns:
      the ring's up vector.
    • setUp

      public void setUp(ReadOnlyVector3 up)
      setUp sets the ring's up vector.
      Parameters:
      up - the ring's up vector.
    • getInnerRadius

      public double getInnerRadius()
      getInnerRadius returns the ring's inner radius.
      Specified by:
      getInnerRadius in interface ReadOnlyRing
      Returns:
      the ring's inner radius.
    • setInnerRadius

      public void setInnerRadius(double innerRadius)
      setInnerRadius sets the ring's inner radius.
      Parameters:
      innerRadius - the ring's inner radius.
    • getOuterRadius

      public double getOuterRadius()
      getOuterRadius returns the ring's outer radius.
      Specified by:
      getOuterRadius in interface ReadOnlyRing
      Returns:
      the ring's outer radius.
    • setOuterRadius

      public void setOuterRadius(double outerRadius)
      setOuterRadius sets the ring's outer radius.
      Parameters:
      outerRadius - the ring's outer radius.
    • random

      public Vector3 random(Vector3 store)
      random returns a random point within the ring.
      Specified by:
      random in interface ReadOnlyRing
      Parameters:
      store - Vector to store result in
      Returns:
      a random point within the ring.
    • isValid

      public static boolean isValid(ReadOnlyRing ring)
      Check a ring... if it is null or its radii, or the doubles of its center or up are NaN or infinite, return false. Else return true.
      Parameters:
      ring - the ring to check
      Returns:
      true or false as stated above.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the string representation of this ring.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      returns a unique code for this ring object based on its values. If two rings are numerically equal, they will return the same hash code value.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare for equality
      Returns:
      true if this ring and the provided ring have the same constant and normal values.
    • clone

      public Ring clone()
      Specified by:
      clone in interface ReadOnlyRing
      Overrides:
      clone in class Object
    • getClassTag

      public Class<? extends Ring> getClassTag()
      Specified by:
      getClassTag in interface Savable
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Used with serialization. Not to be called manually.
      Specified by:
      readExternal in interface Externalizable
      Parameters:
      in - ObjectInput
      Throws:
      IOException - if something wrong occurs while reading
      ClassNotFoundException - if a class is not found
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Used with serialization. Not to be called manually.
      Specified by:
      writeExternal in interface Externalizable
      Parameters:
      out - ObjectOutput
      Throws:
      IOException - if something wrong occurs while writing
    • fetchTempInstance

      public static final Ring fetchTempInstance()
      Returns:
      An instance of Ring that is intended for temporary use in calculations and so forth. Multiple calls to the method should return instances of this class that are not currently in use.
    • releaseTempInstance

      public static final void releaseTempInstance(Ring ring)
      Releases a Ring back to be used by a future call to fetchTempInstance. TAKE CARE: this Ring object should no longer have other classes referencing it or "Bad Things" will happen.
      Parameters:
      ring - the Ring to release.