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 AABB

    java.lang.Object
      toxi.geom.Vec3D
          toxi.geom.AABB

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

Direct Known Subclasses:
  PointOctree

    public class AABB

extends Vec3D
implements Shape3D

Axis-aligned bounding box with basic intersection features for Ray, AABB and Sphere classes.

Nested Class Summary

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

Field Summary

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

Constructor Summary
`AABB()`
`AABB(AABB box)` Creates an independent copy of the passed in box
`AABB(float extent)` Creates a new box of the given size at the world origin.
`AABB(ReadonlyVec3D pos, float extent)` Creates a new instance from centre point and uniform extent in all directions.
`AABB(ReadonlyVec3D pos, ReadonlyVec3D extent)` Creates a new instance from centre point and extent

Method Summary
`boolean` | `containsPoint(ReadonlyVec3D p)` Checks if the point is within the given shape/volume.
`AABB` | `copy()` Copy.
`static AABB` | `fromMinMax(Vec3D min, Vec3D max)` Creates a new instance from two vectors specifying opposite corners of the box
`Vec3D` | `getExtent()` Returns the current box size as new Vec3D instance (updating this vector will NOT update the box size! Use `setExtent(ReadonlyVec3D)` for those purposes)
`Vec3D` | `getMax()`
`Vec3D` | `getMin()`
`Vec3D` | `getNormalForPoint(ReadonlyVec3D p)`
`AABB` | `includePoint(ReadonlyVec3D p)` Adjusts the box size and position such that it includes the given point.
`boolean` | `intersectsBox(AABB box)` Checks if the box intersects the passed in one.
`Vec3D` | `intersectsRay(Ray3D ray, float minDist, float maxDist)` Calculates intersection with the given ray between a certain distance interval.
`boolean` | `intersectsSphere(Sphere s)`
`boolean` | `intersectsSphere(Vec3D c, float r)`
`boolean` | `intersectsTriangle(Triangle3D tri)`
`AABB` | `set(AABB box)`
`Vec3D` | `set(float x, float y, float z)` Updates the position of the box in space and calls `updateBounds()` immediately
`AABB` | `set(ReadonlyVec3D v)` Updates the position of the box in space and calls `updateBounds()` immediately
`AABB` | `setExtent(ReadonlyVec3D extent)` Updates the size of the box and calls `updateBounds()` immediately
`Mesh3D` | `toMesh()`
`Mesh3D` | `toMesh(Mesh3D mesh)`
`java.lang.String` | `toString()`
`AABB` | `updateBounds()` Updates the min/max corner points of the box.

Methods inherited from class toxi.geom.Vec3D
`abs, add, add, add, addSelf, addSelf, angleBetween, angleBetween, clear, compareTo, constrain, constrain, 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, setComponent, setComponent, setXY, shuffle, signum, sub, sub, sub, subSelf, subSelf, to2DXY, to2DXZ, to2DYZ, toArray, toArray4, toCartesian, toSpherical, x, y, z`

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

Constructor Detail

### AABB

    public AABB()

### AABB

    public AABB(AABB box)

  Creates an independent copy of the passed in box

  Parameters:
    `box` -

### AABB

    public AABB(float extent)

  Creates a new box of the given size at the world origin.

  Parameters:
    `extent` -

### AABB

    public AABB(ReadonlyVec3D pos,
                float extent)

  Creates a new instance from centre point and uniform extent in all directions.

  Parameters:
    `pos` -
    `extent` -

### AABB

    public AABB(ReadonlyVec3D pos,
                ReadonlyVec3D extent)

  Creates a new instance from centre point and extent

  Parameters:
    `pos` -
    `extent` - box dimensions (the box will be double the size in each direction)

Method Detail

### fromMinMax

    public static final AABB fromMinMax(Vec3D min,
                                        Vec3D max)

  Creates a new instance from two vectors specifying opposite corners of the box

  Parameters:
    `min` - first corner point
    `max` - second corner point
  Returns:
    new AABB with centre at the half point between the 2 input vectors

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

### copy

    public AABB copy()

  Description copied from interface: `ReadonlyVec3D`
  Copy.

  Specified by:
    `copy` in interface `ReadonlyVec3D`
  Overrides:
    `copy` in class `Vec3D`
  Returns:
    a new independent instance/copy of a given vector

### getExtent

    public final Vec3D getExtent()

  Returns the current box size as new Vec3D instance (updating this vector will NOT update the box size! Use `setExtent(ReadonlyVec3D)` for those purposes)

  Returns:
    box size

### getMax

    public final Vec3D getMax()

### getMin

    public final Vec3D getMin()

### getNormalForPoint

    public Vec3D getNormalForPoint(ReadonlyVec3D p)

### includePoint

    public AABB includePoint(ReadonlyVec3D p)

  Adjusts the box size and position such that it includes the given point.

  Parameters:
    `p` - point to include
  Returns:
    itself

### intersectsBox

    public boolean intersectsBox(AABB box)

  Checks if the box intersects the passed in one.

  Parameters:
    `box` - box to check
  Returns:
    true, if boxes overlap

### intersectsRay

    public Vec3D intersectsRay(Ray3D ray,
                               float minDist,
                               float maxDist)

  Calculates intersection with the given ray between a certain distance interval. Ray-box intersection is using IEEE numerical properties to ensure the test is both robust and efficient, as described in: Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley: "An Efficient and Robust Ray-Box Intersection Algorithm" Journal of graphics tools, 10(1):49-54, 2005

  Parameters:
    `ray` - incident ray
    `minDist` -
    `maxDist` -
  Returns:
    intersection point on the bounding box (only the first is returned) or null if no intersection

### intersectsSphere

    public boolean intersectsSphere(Sphere s)

### intersectsSphere

    public boolean intersectsSphere(Vec3D c,
                                    float r)

  Parameters:
    `c` - sphere centre
    `r` - sphere radius
  Returns:
    true, if AABB intersects with sphere

### intersectsTriangle

    public boolean intersectsTriangle(Triangle3D tri)

### set

    public AABB set(AABB box)

### set

    public Vec3D set(float x,
                     float y,
                     float z)

  Updates the position of the box in space and calls `updateBounds()` immediately

  Overrides:
    `set` in class `Vec3D`
  Parameters:
    `x` - the x
    `y` - the y
    `z` - the z
  Returns:
    itself
  See Also:
    `Vec3D.set(float, float, float)`

### set

    public AABB set(ReadonlyVec3D v)

  Updates the position of the box in space and calls `updateBounds()` immediately

  Overrides:
    `set` in class `Vec3D`
  See Also:
    `Vec3D.set(toxi.geom.Vec3D)`

### setExtent

    public AABB setExtent(ReadonlyVec3D extent)

  Updates the size of the box and calls `updateBounds()` immediately

  Parameters:
    `extent` - new box size
  Returns:
    itself, for method chaining

### toMesh

    public Mesh3D toMesh()

### toMesh

    public Mesh3D toMesh(Mesh3D mesh)

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `Vec3D`

### updateBounds

    public final AABB updateBounds()

  Updates the min/max corner points of the box. MUST be called after moving the box in space by manipulating the public x,y,z coordinates directly.

  Returns:
    itself

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