public final class Ray
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
float |
dx |
float |
dy |
float |
dz |
float |
ox |
float |
oy |
float |
oz |
Constructor and Description |
---|
Ray(float ox,
float oy,
float oz,
float dx,
float dy,
float dz)
Creates a new ray that points from the given origin to the given
direction.
|
Ray(Point3 a,
Point3 b)
Creates a new ray that points from point a to point b.
|
Ray(Point3 o,
Vector3 d)
Creates a new ray that points from the given origin to the given
direction.
|
Modifier and Type | Method and Description |
---|---|
float |
dot(float vx,
float vy,
float vz)
Computes the dot product of an arbitrary vector with the direction of the
ray.
|
float |
dot(Vector3 v)
Computes the dot product of an arbitrary vector with the direction of the
ray.
|
Vector3 |
getDirection()
Creates a vector to represent the direction of the ray.
|
float |
getMax()
Gets the maximum distance along the ray.
|
float |
getMin()
Gets the minimum distance along the ray - usually 0.
|
Point3 |
getPoint(Point3 dest)
Gets the end point of the ray.
|
boolean |
isInside(float t)
Checks to see if the specified distance falls within the valid range on
this ray.
|
void |
normalize()
Normalize the direction component of the ray.
|
void |
setMax(float t)
Updates the maximum to the specified distance if and only if the new
distance is smaller than the current one.
|
void |
setMinMax(float min,
float max) |
Ray |
transform(Matrix4 m)
Create a new ray by transforming the supplied one by the given matrix.
|
public float ox
public float oy
public float oz
public float dx
public float dy
public float dz
public Ray(float ox, float oy, float oz, float dx, float dy, float dz)
ox
- ray origin xoy
- ray origin yoz
- ray origin zdx
- ray direction xdy
- ray direction ydz
- ray direction zpublic Ray(Point3 o, Vector3 d)
o
- ray origind
- ray direction (need not be normalized)public Ray transform(Matrix4 m)
null
, the original ray is returned.m
- matrix to transform the ray bypublic void normalize()
public final float getMin()
public final float getMax()
public final Vector3 getDirection()
public final boolean isInside(float t)
t
- distance to be testedtrue
if t falls between the minimum and maximum
distance of this ray, false
otherwisepublic final Point3 getPoint(Point3 dest)
dest
is
returned to support chaining.dest
- reference to the point to storedest
public final float dot(Vector3 v)
v
- vectorpublic final float dot(float vx, float vy, float vz)
vx
- vector x coordinatevy
- vector y coordinatevz
- vector z coordinatepublic final void setMax(float t)
t
- new maximum distancepublic void setMinMax(float min, float max)