Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## toxi.geom
Class Sphere

    java.lang.Object
      toxi.geom.Vec3D
          toxi.geom.Sphere

All Implemented Interfaces:
  java.lang.Comparable<ReadonlyVec3D>, ReadonlyVec3D, Shape3D

    public class Sphere

extends Vec3D
implements Shape3D

Nested Class Summary

Nested classes/interfaces inherited from class toxi.geom.Vec3D
`Vec3D.Axis`

Field Summary
`float` | `radius`

Fields inherited from class toxi.geom.Vec3D
`MAX_VALUE, MIN_VALUE, x, X_AXIS, y, Y_AXIS, z, Z_AXIS, ZERO`

Constructor Summary
`Sphere()`
`Sphere(float radius)`
`Sphere(ReadonlyVec3D v, float r)`
`Sphere(Sphere s)`

Method Summary
`boolean` | `containsPoint(ReadonlyVec3D p)` Checks if the point is within the given shape/volume.
`float[]` | `intersectRay(Ray3D ray)` Alternative to `SphereIntersectorReflector`.
`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.
`Vec3D` | `tangentPlaneNormalAt(ReadonlyVec3D q)` Calculates the normal vector on the sphere in the direction of the current point.
`Mesh3D` | `toMesh(int res)`
`Mesh3D` | `toMesh(Mesh3D mesh, int res)`

Methods inherited from class toxi.geom.Vec3D
`abs, add, add, add, addSelf, addSelf, angleBetween, angleBetween, clear, compareTo, constrain, constrain, copy, cross, cross, crossInto, crossSelf, distanceTo, distanceToSquared, dot, dot, equals, equalsWithTolerance, floor, frac, fromXYTheta, fromXZTheta, fromYZTheta, getAbs, getComponent, getComponent, getConstrained, getFloored, getFrac, getInverted, getLimited, getNormalized, getNormalizedTo, getReciprocal, getReflected, getRotatedAroundAxis, getRotatedX, getRotatedY, getRotatedZ, getSignum, hashCode, headingXY, headingXZ, headingYZ, immutable, interpolateTo, interpolateTo, interpolateTo, interpolateTo, interpolateToSelf, interpolateToSelf, invert, isInAABB, isInAABB, isMajorAxis, isZeroVector, jitter, jitter, jitter, jitter, jitter, jitter, limit, magnitude, magSquared, max, maxSelf, min, minSelf, modSelf, modSelf, normalize, normalizeTo, randomVector, randomVector, reciprocal, reflect, rotateAroundAxis, rotateX, rotateY, rotateZ, roundToAxis, scale, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, set, set, set, setComponent, setComponent, setXY, shuffle, signum, sub, sub, sub, subSelf, subSelf, to2DXY, to2DXZ, to2DYZ, toArray, toArray4, toCartesian, toSpherical, toString, x, y, z`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### radius

    public float radius

Constructor Detail

### Sphere

    public Sphere()

### Sphere

    public Sphere(float radius)

### Sphere

    public Sphere(ReadonlyVec3D v,
                  float r)

### Sphere

    public Sphere(Sphere s)

Method Detail

### 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

### 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)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD