Class Sphere

  • All Implemented Interfaces:
    java.io.Serializable

    public class Sphere
    extends java.lang.Object
    implements java.io.Serializable
    Encapsulates a 3D sphere with a center and a radius
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      Vector3 center
      the center of the sphere
      float radius
      the radius of the sphere
    • Constructor Summary

      Constructors 
      Constructor Description
      Sphere​(Vector3 center, float radius)
      Constructs a sphere with the given center and radius
    • Field Detail

      • radius

        public float radius
        the radius of the sphere
      • center

        public final Vector3 center
        the center of the sphere
    • Constructor Detail

      • Sphere

        public Sphere​(Vector3 center,
                      float radius)
        Constructs a sphere with the given center and radius
        Parameters:
        center - The center
        radius - The radius
    • Method Detail

      • overlaps

        public boolean overlaps​(Sphere sphere)
        Parameters:
        sphere - the other sphere
        Returns:
        whether this and the other sphere overlap
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • volume

        public float volume()
      • surfaceArea

        public float surfaceArea()