optics
Class Position

java.lang.Object
  extended by javax.vecmath.Tuple3d
      extended by javax.vecmath.Point3d
          extended by optics.Position
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
SourcePoint

public class Position
extends javax.vecmath.Point3d

Class to implement a three-dimensional position held as three doubles with some support methods to help in ray propagation.

This class extends the Point3d from the javax.vecmath package with is part of Java3D

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.vecmath.Tuple3d
x, y, z
 
Constructor Summary
Position()
          Default constructor all three coordinates defaulting to zero.
Position(double z)
          Constructor with one double, being z, with x and y defaulting to zero.
Position(double x, double y)
          Constructor with two doubles, being x and y with z defaulting to zero.
Position(double x, double y, double z)
          Constructor with three doubles.
Position(javax.vecmath.Tuple2d t)
          Constructor with position specified any double Truple2d with z defaulting to zero.
Position(javax.vecmath.Tuple2d t, double z)
          Constructor with position specified any double Truple2d and a specified z.
Position(javax.vecmath.Tuple3d t)
          Constructor with position specified any double Truple3d
 
Method Summary
 void add(double dx, double dy, double dz)
          Method to add to the current position
 Position clone()
          Clone method to clone the Position.
 Director direction(javax.vecmath.Tuple3d p)
          Method to get the Director from the current Position to the specified Position
static Position fromString(java.lang.String s)
          Static method to parse a Position from a String which contains three doubles separated by spaces, commas or () in any order.
static Position fromTokens(java.util.StringTokenizer tokens)
          Static method to parse a Position from StringTokenizer tokens.
 javax.vecmath.Point2d getPoint2d()
          Method to get the x/y locations as a Point2d
 double length()
          Calculate the length from origin.
 double length(javax.vecmath.Tuple3d p)
          Calcuate the length from specified Truple3d
 double lengthSquared()
          Calculate the length squared from origin.
 double lengthSquared(javax.vecmath.Tuple3d p)
          Calcuate the length square from a specified Tuple3d
 void max(javax.vecmath.Tuple3d p)
          Method to take the maximum of the current point and a specified point treatimg all three coordinates separetely.
 void min(javax.vecmath.Tuple3d p)
          Method to take the minimum of the current point and a specified point treating all three coordinates separetely.
 void propagate(javax.vecmath.Tuple3d u, double d)
          Method to propagated the current point a distance d in the direction u.
 
Methods inherited from class javax.vecmath.Point3d
distance, distanceL1, distanceLinf, distanceSquared, project
 
Methods inherited from class javax.vecmath.Tuple3d
absolute, absolute, add, add, clamp, clamp, clamp, clamp, clampMax, clampMax, clampMax, clampMax, clampMin, clampMin, clampMin, clampMin, epsilonEquals, equals, equals, get, get, getX, getY, getZ, hashCode, interpolate, interpolate, interpolate, interpolate, negate, negate, scale, scale, scaleAdd, scaleAdd, scaleAdd, set, set, set, set, setX, setY, setZ, sub, sub, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Position

public Position(double x,
                double y,
                double z)
Constructor with three doubles.

Parameters:
x - the X value
y - the Y value
z - the Z value

Position

public Position(double x,
                double y)
Constructor with two doubles, being x and y with z defaulting to zero.

Parameters:
x - the X value
y - the Y value

Position

public Position(double z)
Constructor with one double, being z, with x and y defaulting to zero.

Parameters:
z - the Z location

Position

public Position()
Default constructor all three coordinates defaulting to zero.


Position

public Position(javax.vecmath.Tuple3d t)
Constructor with position specified any double Truple3d

Parameters:
t - the Truple3d

Position

public Position(javax.vecmath.Tuple2d t,
                double z)
Constructor with position specified any double Truple2d and a specified z.

Parameters:
t - specified the x and y
z -

Position

public Position(javax.vecmath.Tuple2d t)
Constructor with position specified any double Truple2d with z defaulting to zero.

Parameters:
t - specified the x and y
Method Detail

clone

public Position clone()
Clone method to clone the Position.

Overrides:
clone in class javax.vecmath.Tuple3d
Returns:
Position clone of Position

lengthSquared

public double lengthSquared()
Calculate the length squared from origin.

Returns:
double length squared

length

public double length()
Calculate the length from origin.

Returns:
double the length.

lengthSquared

public double lengthSquared(javax.vecmath.Tuple3d p)
Calcuate the length square from a specified Tuple3d

Parameters:
p - the specified Truple3d
Returns:
double length squared to specified point

length

public double length(javax.vecmath.Tuple3d p)
Calcuate the length from specified Truple3d

Parameters:
p - the specified Truple3d
Returns:
double length to specified point

getPoint2d

public javax.vecmath.Point2d getPoint2d()
Method to get the x/y locations as a Point2d

Returns:
Point2d the x/y location as a Point2d.

add

public void add(double dx,
                double dy,
                double dz)
Method to add to the current position

Parameters:
dx - the x value
dy - the y value
dz - the z value

propagate

public void propagate(javax.vecmath.Tuple3d u,
                      double d)
Method to propagated the current point a distance d in the direction u.

Note this method does not check for invalid operations.

Parameters:
u - the direction
d - the distance

min

public void min(javax.vecmath.Tuple3d p)
Method to take the minimum of the current point and a specified point treating all three coordinates separetely.

Parameters:
p - the specified point

max

public void max(javax.vecmath.Tuple3d p)
Method to take the maximum of the current point and a specified point treatimg all three coordinates separetely.

Parameters:
p - the specified point

direction

public Director direction(javax.vecmath.Tuple3d p)
Method to get the Director from the current Position to the specified Position

Parameters:
p - the second Position

fromString

public static Position fromString(java.lang.String s)
Static method to parse a Position from a String which contains three doubles separated by spaces, commas or () in any order. It used StringTokenizer to the parsing.

Parameters:
s - the String containing the position.
Returns:
Position the parsed Position, null if anything fails.

fromTokens

public static Position fromTokens(java.util.StringTokenizer tokens)
Static method to parse a Position from StringTokenizer tokens. It assumes there are three tokens with the x,y,z which can be read.

Parameters:
tokens - the tokens
Returns:
Position the parsed Position, null if anything fails.