com.threerings.math
Class Ray2D

java.lang.Object
  extended by com.threerings.math.Ray2D

public final class Ray2D
extends Object

A ray consisting of an origin point and a unit direction vector.


Constructor Summary
Ray2D()
          Creates an empty (invalid) ray.
Ray2D(Ray2D other)
          Copy constructor.
Ray2D(Vector2f origin, Vector2f direction)
          Creates a ray with the values contained in the supplied origin point and unit direction vector.
 
Method Summary
 Vector2f getDirection()
          Returns a reference to the ray's unit direction vector.
 boolean getIntersection(Vector2f center, float radius, Vector2f result)
          Finds the intersection between the ray and a circle with the given center and radius.
 boolean getIntersection(Vector2f start, Vector2f end, float radius, Vector2f result)
          Finds the intersection between the ray and a capsule with the given start point, end point, and radius.
 boolean getIntersection(Vector2f start, Vector2f end, Vector2f result)
          Finds the intersection between the ray and a line segment with the given start and end points.
 Vector2f getNearestPoint(Vector2f point, Vector2f result)
          Resturns the nearest point on the Ray to the supplied point.
 Vector2f getOrigin()
          Returns a reference to the ray's point of origin.
 boolean intersects(Vector2f pt)
          Determines whether the ray intersects the specified point.
 Ray2D set(Ray2D other)
          Copies the parameters of another ray.
 Ray2D set(Vector2f origin, Vector2f direction)
          Sets the ray parameters to the values contained in the supplied vectors.
 String toString()
           
 Ray2D transform(Transform2D transform)
          Transforms this ray.
 Ray2D transform(Transform2D transform, Ray2D result)
          Transforms this ray, placing the result in the object provided.
 Ray2D transformLocal(Transform2D transform)
          Transforms this ray in-place.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ray2D

public Ray2D(Vector2f origin,
             Vector2f direction)
Creates a ray with the values contained in the supplied origin point and unit direction vector.


Ray2D

public Ray2D(Ray2D other)
Copy constructor.


Ray2D

public Ray2D()
Creates an empty (invalid) ray.

Method Detail

getOrigin

public Vector2f getOrigin()
Returns a reference to the ray's point of origin.


getDirection

public Vector2f getDirection()
Returns a reference to the ray's unit direction vector.


transformLocal

public Ray2D transformLocal(Transform2D transform)
Transforms this ray in-place.

Returns:
a reference to this ray, for chaining.

transform

public Ray2D transform(Transform2D transform)
Transforms this ray.

Returns:
a new ray containing the result.

transform

public Ray2D transform(Transform2D transform,
                       Ray2D result)
Transforms this ray, placing the result in the object provided.

Returns:
a reference to the result ray, for chaining.

set

public Ray2D set(Ray2D other)
Copies the parameters of another ray.

Returns:
a reference to this ray, for chaining.

set

public Ray2D set(Vector2f origin,
                 Vector2f direction)
Sets the ray parameters to the values contained in the supplied vectors.

Returns:
a reference to this ray, for chaining.

intersects

public boolean intersects(Vector2f pt)
Determines whether the ray intersects the specified point.


getIntersection

public boolean getIntersection(Vector2f start,
                               Vector2f end,
                               Vector2f result)
Finds the intersection between the ray and a line segment with the given start and end points.

Returns:
true if the ray intersected the segment (in which case the result will contain the point of intersection), false otherwise.

getIntersection

public boolean getIntersection(Vector2f start,
                               Vector2f end,
                               float radius,
                               Vector2f result)
Finds the intersection between the ray and a capsule with the given start point, end point, and radius.

Returns:
true if the ray intersected the circle (in which case the result will contain the point of intersection), false otherwise.

getIntersection

public boolean getIntersection(Vector2f center,
                               float radius,
                               Vector2f result)
Finds the intersection between the ray and a circle with the given center and radius.

Returns:
true if the ray intersected the circle (in which case the result will contain the point of intersection), false otherwise.

getNearestPoint

public Vector2f getNearestPoint(Vector2f point,
                                Vector2f result)
Resturns the nearest point on the Ray to the supplied point.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.