y25.graphics
Class Point3D

java.lang.Object
  extended byy25.graphics.Point3D

public class Point3D
extends Object

Represents a point in three dimensional space.

A point's x,y and z coordinates can be retrieved and set by accessing it's x,y and z members directly, e.g. point.x = 3*point.z.

Most operations on a Point3D can be chained, since a reference to the point is returned by most methods, e.g. point.set(2,3,4).translate(-1,2,3).


Field Summary
 float x
          The x-coordinate of the point.
 float y
          The y-coordinate of the point.
 float z
          The z-coordinate of the point.
 
Constructor Summary
Point3D()
          Creates a point at (0,0,0).
Point3D(float xx, float yy, float zz)
          Creates a point at the given coordinates.
Point3D(Point3D p)
          Creates a point at the same position as the passed point.
Point3D(Vector3D v)
          Creates a point by interpreting the passed vector as a position vector.
 
Method Summary
 Point3D getTranslated(Vector3D v)
          Creates a copy of this point, translates it by the given vector and returns the copy.
 Vector3D getVector3D()
          Returns a Vector3D with the same x,y,z entries as this point.
 boolean isZero()
          Returns true if this point lies at the origin, false otherwise.
static Point3D lerp(Point3D a, Point3D b, float amount)
          Performs a linear interpolation between two points.
 Point3D set(float xx, float yy, float zz)
          Sets this point to the given coordinates and returns a reference to this point.
 Point3D set(Point3D p)
          Sets this point to the same coordinates as the passed one and returns a reference to this point.
 Point3D set(Vector3D v)
          Sets this point to the same coordinates as the passed vector and returns a reference to this point.
 String toString()
           
 Point3D translate(Vector3D v)
          Translates this point by the given vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public float x
The x-coordinate of the point.


y

public float y
The y-coordinate of the point.


z

public float z
The z-coordinate of the point.

Constructor Detail

Point3D

public Point3D()
Creates a point at (0,0,0).


Point3D

public Point3D(float xx,
               float yy,
               float zz)
Creates a point at the given coordinates.


Point3D

public Point3D(Point3D p)
Creates a point at the same position as the passed point.


Point3D

public Point3D(Vector3D v)
Creates a point by interpreting the passed vector as a position vector.

Method Detail

set

public Point3D set(float xx,
                   float yy,
                   float zz)
Sets this point to the given coordinates and returns a reference to this point.


set

public Point3D set(Point3D p)
Sets this point to the same coordinates as the passed one and returns a reference to this point.


set

public Point3D set(Vector3D v)
Sets this point to the same coordinates as the passed vector and returns a reference to this point.


isZero

public boolean isZero()
Returns true if this point lies at the origin, false otherwise.


translate

public Point3D translate(Vector3D v)
Translates this point by the given vector. In mathematical notation, this would be point = point + vector.


getTranslated

public Point3D getTranslated(Vector3D v)
Creates a copy of this point, translates it by the given vector and returns the copy.


toString

public String toString()

lerp

public static Point3D lerp(Point3D a,
                           Point3D b,
                           float amount)
Performs a linear interpolation between two points.

If amount is 0, a new point at position a is returned, if amount is 1, a point at position b is returned. For values between 0 and 1, a and b are interpolated. For values in the range (-inf,0) and (1,inf), a and b are extrapolated.


getVector3D

public Vector3D getVector3D()
Returns a Vector3D with the same x,y,z entries as this point.