keps.math
Class Point3

java.lang.Object
  extended by keps.math.Tuple3
      extended by keps.math.Point3

public class Point3
extends Tuple3

GENERAL CONTRACT FOR ALL MATH CLASSES. -- The destination of every method is assumed to be the object the method was called on. For example: c.add(a,b) means c = a + b. -- Whenever one operand of a binary operand is missing, it is assumed to be the object the method was called upon. For example: c.add(a) means c = c + a. Class for 3d points.

Author:
arbree Aug 18, 2005 Point3.java Copyright 2005 Program of Computer Graphics, Cornell University

Field Summary
 
Fields inherited from class keps.math.Tuple3
x, y, z
 
Constructor Summary
Point3()
          Default constructor.
Point3(double newX, double newY, double newZ)
          The explicit constructor.
Point3(Point3 newTuple)
          Copy constructor.
 
Method Summary
 void add(Point3 point, Vector3 vector)
          Add a Vector3 to a Point3 and store the result in this Point3
 void add(Vector3 vector)
          Add a Vector3 to this Point3
 double distance(Point3 other)
          Returns the distance from this Point3 to other
 double distanceSquared(Point3 other)
          Returns the squared distance from this Point3 to other
 void scaleAdd(double scale, Vector3 vector)
          Add a scaled multiple of a Vector3 to this Point3
 void sub(Point3 point, Vector3 vector)
          Subtract a Vector3 from a Point3 and store the result in this Point3
 void sub(Vector3 vector)
          Subtract a Vector3 to this Point3
 java.lang.String toString()
           
 
Methods inherited from class keps.math.Tuple3
scale, set, set
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point3

public Point3()
Default constructor. Uses explicit constructor to create a zero vector.


Point3

public Point3(Point3 newTuple)
Copy constructor. This constructor simply calls the explicit constructor with the necessary fields from the input as parameters.

Parameters:
newTuple - The Point3 to copy.

Point3

public Point3(double newX,
              double newY,
              double newZ)
The explicit constructor. This is the only constructor with any real code in it. Values should be set here, and any variables that need to be calculated should be done here.

Parameters:
newX - The x value of the new Point3.
newY - The y value of the new Point3.
newZ - The z value of the new Point3.
Method Detail

distanceSquared

public double distanceSquared(Point3 other)
Returns the squared distance from this Point3 to other

Parameters:
other - another point
Returns:
the squared distance from this point to the other point

distance

public double distance(Point3 other)
Returns the distance from this Point3 to other

Parameters:
other - another point
Returns:
the distance

add

public void add(Vector3 vector)
Add a Vector3 to this Point3

Parameters:
vector - the Vector3 to add

add

public void add(Point3 point,
                Vector3 vector)
Add a Vector3 to a Point3 and store the result in this Point3

Parameters:
point - the input point
vector - the input vector

sub

public void sub(Vector3 vector)
Subtract a Vector3 to this Point3

Parameters:
vector - the Vector3 to substract

sub

public void sub(Point3 point,
                Vector3 vector)
Subtract a Vector3 from a Point3 and store the result in this Point3

Parameters:
point - the input point
vector - the input vector

scaleAdd

public void scaleAdd(double scale,
                     Vector3 vector)
Add a scaled multiple of a Vector3 to this Point3

Parameters:
scale - the input scale
vector - the input vector

toString

public java.lang.String toString()
Overrides:
toString in class Tuple3
See Also:
Object.toString()