org.sunflow.core
Class Ray
public final class Ray
extends java.lang.Object
This class represents a ray as a oriented half line segment. The ray
direction is always normalized. The valid region is delimted by two distances
along the ray, tMin and tMax.
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.
|
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.
|
Ray | transform(Matrix4 m) - Create a new ray by transforming the supplied one by the given matrix.
|
Ray
public 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. The ray has infinite length. The direction vector is
normalized.
ox
- ray origin xoy
- ray origin yoz
- ray origin zdx
- ray direction xdy
- ray direction ydz
- ray direction z
Ray
public Ray(Point3 a,
Point3 b)
Creates a new ray that points from point a to point b. The created ray
will set tMin and tMax to limit the ray to the segment (a,b)
(non-inclusive of a and b). This is often used to create shadow rays.
a
- start pointb
- end point
Ray
public Ray(Point3 o,
Vector3 d)
Creates a new ray that points from the given origin to the given
direction. The ray has infinite length. The direction vector is
normalized.
o
- ray origind
- ray direction (need not be normalized)
dot
public final float dot(float vx,
float vy,
float vz)
Computes the dot product of an arbitrary vector with the direction of the
ray. This method avoids having to call getDirection() which would
instantiate a new Vector object.
vx
- vector x coordinatevy
- vector y coordinatevz
- vector z coordinate
- dot product of the ray direction and the specified vector
dot
public final float dot(Vector3 v)
Computes the dot product of an arbitrary vector with the direction of the
ray. This method avoids having to call getDirection() which would
instantiate a new Vector object.
- dot product of the ray direction and the specified vector
getDirection
public final Vector3 getDirection()
Creates a vector to represent the direction of the ray.
- a vector equal to the direction of this ray
getMax
public final float getMax()
Gets the maximum distance along the ray. May be infinite.
- value of the largest distance along the ray
getMin
public final float getMin()
Gets the minimum distance along the ray - usually 0.
- value of the smallest distance along the ray
getPoint
public final Point3 getPoint(Point3 dest)
Gets the end point of the ray. A reference to dest
is
returned to support chaining.
dest
- reference to the point to store
isInside
public final boolean isInside(float t)
Checks to see if the specified distance falls within the valid range on
this ray. This should always be used before an intersection with the ray
is detected.
t
- distance to be tested
true
if t falls between the minimum and maximum
distance of this ray, false
otherwise
normalize
public void normalize()
Normalize the direction component of the ray.
setMax
public final void setMax(float t)
Updates the maximum to the specified distance if and only if the new
distance is smaller than the current one.
transform
public Ray transform(Matrix4 m)
Create a new ray by transforming the supplied one by the given matrix. If
the matrix is null
, the original ray is returned.
m
- matrix to transform the ray by