gnu.gleem.linalg
Class PlaneUV

java.lang.Object
  |
  +--gnu.gleem.linalg.PlaneUV

public class PlaneUV
extends java.lang.Object

This differs from the Plane class in that it maintains an origin and orthonormal U, V axes in the plane so that it can project a 3D point to a 2D one. U cross V = normal. U and V coordinates are computed with respect to the origin.


Constructor Summary
PlaneUV()
          Default constructor initializes normal to (0, 1, 0), origin to (0, 0, 0), U axis to (1, 0, 0) and V axis to (0, 0, -1).
PlaneUV(Vec3f normal, Vec3f origin)
          Takes normal vector and a point which the plane goes through (which becomes the plane's "origin").
PlaneUV(Vec3f normal, Vec3f origin, Vec3f uAxis)
          Takes normal vector, point which plane goes through, and the "u" axis in the plane.
PlaneUV(Vec3f normal, Vec3f origin, Vec3f uAxis, Vec3f vAxis)
          Takes normal vector, point which plane goes through, and both the u and v axes.
 
Method Summary
 Vec3f getNormal()
          Normal, U and V axes are normalized internally, so, for example, normal is not necessarily equal to plane.setNormal(normal); plane.getNormal();
 Vec3f getOrigin()
           
 Vec3f getUAxis()
           
 Vec3f getVAxis()
           
 boolean intersectRay(Vec3f rayStart, Vec3f rayDirection, IntersectionPoint intPt, Vec2f uvCoords)
          Intersect a ray with this plane, outputting not only the 3D intersection point but also the U, V coordinates of the intersection.
 void projectPoint(Vec3f point, Vec3f projPt, Vec2f uvCoords)
          Project a point onto the plane
 void setNormal(Vec3f normal)
          This version sets the normal vector and generates new U and V axes.
 void setNormalAndU(Vec3f normal, Vec3f uAxis)
          This version computes the V axis from (normal cross U).
 void setNormalAndUV(Vec3f normal, Vec3f uAxis, Vec3f vAxis)
          Normal, U and V axes must be orthogonal and satisfy U cross V = normal, do not need to be unit length but must not be the zero vector.
 void setOrigin(Vec3f origin)
          Set the origin, through which this plane goes and with respect to which U and V coordinates are computed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlaneUV

public PlaneUV()
Default constructor initializes normal to (0, 1, 0), origin to (0, 0, 0), U axis to (1, 0, 0) and V axis to (0, 0, -1).


PlaneUV

public PlaneUV(Vec3f normal,
               Vec3f origin)
Takes normal vector and a point which the plane goes through (which becomes the plane's "origin"). Normal does NOT have to be normalized, but may not be zero vector. U and V axes are initialized to arbitrary values.


PlaneUV

public PlaneUV(Vec3f normal,
               Vec3f origin,
               Vec3f uAxis)
Takes normal vector, point which plane goes through, and the "u" axis in the plane. Computes the "v" axis by taking the cross product of the normal and the u axis. Axis must be perpendicular to normal. Normal and uAxis do NOT have to be normalized, but neither may be the zero vector.


PlaneUV

public PlaneUV(Vec3f normal,
               Vec3f origin,
               Vec3f uAxis,
               Vec3f vAxis)
Takes normal vector, point which plane goes through, and both the u and v axes. u axis cross v axis = normal. Normal, uAxis, and vAxis do NOT have to be normalized, but none may be the zero vector.

Method Detail

setOrigin

public void setOrigin(Vec3f origin)
Set the origin, through which this plane goes and with respect to which U and V coordinates are computed


getOrigin

public Vec3f getOrigin()

setNormalAndUV

public void setNormalAndUV(Vec3f normal,
                           Vec3f uAxis,
                           Vec3f vAxis)
Normal, U and V axes must be orthogonal and satisfy U cross V = normal, do not need to be unit length but must not be the zero vector.


setNormal

public void setNormal(Vec3f normal)
This version sets the normal vector and generates new U and V axes.


setNormalAndU

public void setNormalAndU(Vec3f normal,
                          Vec3f uAxis)
This version computes the V axis from (normal cross U).


getNormal

public Vec3f getNormal()
Normal, U and V axes are normalized internally, so, for example, normal is not necessarily equal to plane.setNormal(normal); plane.getNormal();


getUAxis

public Vec3f getUAxis()

getVAxis

public Vec3f getVAxis()

projectPoint

public void projectPoint(Vec3f point,
                         Vec3f projPt,
                         Vec2f uvCoords)
Project a point onto the plane


intersectRay

public boolean intersectRay(Vec3f rayStart,
                            Vec3f rayDirection,
                            IntersectionPoint intPt,
                            Vec2f uvCoords)
Intersect a ray with this plane, outputting not only the 3D intersection point but also the U, V coordinates of the intersection. Returns true if intersection occurred, false otherwise. This is a two-sided ray cast.