NASA World Wind

gov.nasa.worldwind.geom
Class Plane

java.lang.Object
  extended by gov.nasa.worldwind.geom.Plane

public final class Plane
extends Object

A Plane object represents a mathematical plane in an arbitrary cartesian co-ordinate system. A Plane is defined by a normal vector and a distance along that vector from the origin, where the distance represents the distance from the origin to the Plane rather than from the Plane to the origin.

Instances of Plane are immutable.


Constructor Summary
Plane(double a, double b, double c, double d)
          Obtains a new Plane whose normal is defined by the vector (a,b,c) and whose disance from that vector is d.
Plane(Vec4 vec)
          Obtains a new instance of a Plane whose information is contained in Vector vec.
 
Method Summary
 Vec4[] clip(Vec4 pa, Vec4 pb)
          Clip a line segment to this plane.
 Plane computeParallelPlaneAtDistance(double distance)
           
 double distanceTo(Vec4 p)
           
 double dot(Vec4 p)
          Calculates the dot product of this Plane with Vec4 p.
 boolean equals(Object o)
           
 double getDistance()
          Retrieves the distance from the origin to this Plane.
 Vec4 getNormal()
          Retrieves a Vec4 representing the normal to this Plane.
 Vec4 getVector()
          Retrieves a vector representing the normal and distance to this Plane.
 int hashCode()
           
 Vec4 intersect(Line line)
          Determine the point of intersection of a line with this plane.
 Vec4 intersect(Vec4 pa, Vec4 pb)
          Test a line segment for intersection with this plane.
 double intersectDistance(Line line)
          Determine the parametric point of intersection of a line with this plane.
 int onSameSide(Vec4[] pts)
           
 int onSameSide(Vec4 pa, Vec4 pb)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Plane

public Plane(double a,
             double b,
             double c,
             double d)
Obtains a new Plane whose normal is defined by the vector (a,b,c) and whose disance from that vector is d. The vector may not have zero length.

Parameters:
a - the x-parameter of the normal to this Plane
b - the y-parameter of the normal to this Plane
c - the z-parameter of the normal to this Plane
d - the distance of this Plane from the origin along its normal.
Throws:
IllegalArgumentException - if 0==a==b==c

Plane

public Plane(Vec4 vec)
Obtains a new instance of a Plane whose information is contained in Vector vec.

Parameters:
vec - the Vector containing information about this Plane's normal and distance
Throws:
IllegalArgumentException - if passed a null or zero-length Vector
Method Detail

clip

public Vec4[] clip(Vec4 pa,
                   Vec4 pb)
Clip a line segment to this plane.

Parameters:
pa - the first point of the segment.
pb - the second point of the segment.
Returns:
An array of two points that are both on the positive side of the plane. If the direction of the line formed by the two points is positive with respect to this plane's normal vector, the first point in the array will be the intersection point on the plane, and the second point will be the original segment end point. If the direction of the line is negative with respect to this plane's normal vector, the first point in the array will be the original segment's begin point, and the second point will be the intersection point on the plane. If the segment does not intersect the plane, null is returned. If the segment is coincident with the plane, the input points are returned, in their input order.
Throws:
IllegalArgumentException - if either input point is null.

computeParallelPlaneAtDistance

public final Plane computeParallelPlaneAtDistance(double distance)

distanceTo

public double distanceTo(Vec4 p)

dot

public final double dot(Vec4 p)
Calculates the dot product of this Plane with Vec4 p.

Parameters:
p - the Vec4 to dot with this Plane
Returns:
the dot product of p and this Plane
Throws:
IllegalArgumentException - if p is null

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

getDistance

public final double getDistance()
Retrieves the distance from the origin to this Plane. Two options exist for defining distance - the first represents the distance from the origin to the Plane, the second represents the distance from the Plane to the origin. This function uses the first method. The outcome of this is that depending on the caller's view of this method, the sign of distances may appear to be reversed.

Returns:
the distance between this Plane and the origin

getNormal

public final Vec4 getNormal()
Retrieves a Vec4 representing the normal to this Plane.

Returns:
a Vec4 representing the normal to this Plane

getVector

public final Vec4 getVector()
Retrieves a vector representing the normal and distance to this Plane. The vector has the structure (x, y, z, distance), where (x, y, z) represents the normal, and distance represents the distance from the origin.

Returns:
a Vector representation of this Plane

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

intersect

public Vec4 intersect(Line line)
Determine the point of intersection of a line with this plane.

Parameters:
line - the line to test
Returns:
The point on the line at which it intersects the plane. null is returned if the line does not intersect the plane. The line's origin is returned if the line is coincident with the plane.

intersect

public Vec4 intersect(Vec4 pa,
                      Vec4 pb)
Test a line segment for intersection with this plane. If it intersects, return the point of intersection.

Parameters:
pa - the first point of the line segment.
pb - the second point of the line segment.
Returns:
The point of intersection with the plane. Null is returned if the segment does not instersect this plane. Vec4.INFINITY coincident with the plane.
Throws:
IllegalArgumentException - if either input point is null.

intersectDistance

public double intersectDistance(Line line)
Determine the parametric point of intersection of a line with this plane.

Parameters:
line - the line to test
Returns:
The parametric value of the point on the line at which it intersects the plane. Double.NaN is returned if the line does not intersect the plane. Double.POSITIVE_INFINITY is returned if the line is coincident with the plane.

onSameSide

public int onSameSide(Vec4[] pts)

onSameSide

public int onSameSide(Vec4 pa,
                      Vec4 pb)

toString

public final String toString()
Overrides:
toString in class Object

NASA World Wind