Package toxi.geom

Class Sphere

All Implemented Interfaces:
Comparable<ReadonlyVec3D>, ReadonlyVec3D, Shape3D

public class Sphere extends Vec3D implements Shape3D
  • Field Details

    • EARTH_RADIUS

      public static final float EARTH_RADIUS
      Earth's mean radius in km (http://en.wikipedia.org/wiki/Earth_radius#Mean_radii)
      See Also:
    • radius

      public float radius
  • Constructor Details

    • Sphere

      public Sphere()
    • Sphere

      public Sphere(float radius)
    • Sphere

      public Sphere(ReadonlyVec3D v, float r)
    • Sphere

      public Sphere(Sphere s)
  • Method Details

    • containsPoint

      public boolean containsPoint(ReadonlyVec3D p)
      Description copied from interface: Shape3D
      Checks if the point is within the given shape/volume.
      Specified by:
      containsPoint in interface Shape3D
      Returns:
      true, if inside
    • intersectRay

      public float[] intersectRay(Ray3D ray)
      Alternative to SphereIntersectorReflector. Computes primary & secondary intersection points of this sphere with the given ray. If no intersection is found the method returns null. In all other cases, the returned array will contain the distance to the primary intersection point (i.e. the closest in the direction of the ray) as its first index and the other one as its second. If any of distance values is negative, the intersection point lies in the opposite ray direction (might be useful to know). To get the actual intersection point coordinates, simply pass the returned values to Ray3D.getPointAtDistance(float).
      Parameters:
      ray -
      Returns:
      2-element float array of intersection points or null if ray doesn't intersect sphere at all.
    • intersectSphereTriangle

      public boolean intersectSphereTriangle(Triangle3D t, Vec3D result)
      Considers the current vector as centre of a collision sphere with radius r and checks if the triangle abc intersects with this sphere. The Vec3D p The point on abc closest to the sphere center is returned via the supplied result vector argument.
      Parameters:
      t - triangle to check for intersection
      result - a non-null vector for storing the result
      Returns:
      true, if sphere intersects triangle ABC
    • surfaceDistanceBetween

      public double surfaceDistanceBetween(Vec2D p, Vec2D q)
      Computes the surface distance on this sphere between two points given as lon/lat coordinates. The x component of each vector needs to contain the longitude and the y component the latitude (both in radians). Algorithm from: http://www.csgnetwork.com/gpsdistcalc.html
      Parameters:
      p -
      q -
      Returns:
      distance on the sphere surface
    • tangentPlaneNormalAt

      public Vec3D tangentPlaneNormalAt(ReadonlyVec3D q)
      Calculates the normal vector on the sphere in the direction of the current point.
      Parameters:
      q -
      Returns:
      a unit normal vector to the tangent plane of the ellipsoid in the point.
    • toMesh

      public Mesh3D toMesh(int res)
    • toMesh

      public Mesh3D toMesh(Mesh3D mesh, int res)