simogl.geometry
Class Point3D

java.lang.Object
  extended by simogl.geometry.Point3D

public class Point3D
extends java.lang.Object

This class represents a point (or rather vector) in 3-dimensional space. In openGL terms you would call it a vertex.

Author:
Frank Bruns

Constructor Summary
Point3D()
          Creates a new point (vertex) in three-dimensional space that has the coordinates (0,0,0);
Point3D(float x, float y, float z)
          Creates a new point (vertex) in three-dimensional space
Point3D(Point3D point)
           
 
Method Summary
 void add(float x, float y, float z)
          Adds the given parameters to this point
 void add(Point3D point)
          Adds the specified point to this point
 Point3D copy()
          Returns a copy of this point
 void divide(float scalar)
          Divides the point by the specified scalar
 Point3D getCrossProduct(Point3D p1, Point3D p2)
          Returns the result of the cross product of two points/vectors
 float getDotProduct(Point3D p1, Point3D p2)
          Returns the dot product of the two points/vectors.
 float getLength()
          Returns the length of this point (or rather vector)
 float[] getPoint()
          Returns the point (vertex) with its 3D coordinates (x,y,z)
 float getX()
          Returns the x-coordinate of the 3D point (vertex)
 float getY()
          Returns the y-coordinate of the 3D point (vertex)
 float getZ()
          Returns the z-coordinate of the 3D point (vertex)
 boolean isEqualTo(float x, float y, float z)
          Checks if this point is equal to the specified coordinates
 boolean isEqualTo(Point3D point)
          Checks if this point is equal to the given point.
 void multiply(float scalar)
          Multiplies the point by the specified scalar
 void normalize()
          Converts this point (or rather vector) to a vector of length 1.
 void setTo(float x, float y, float z)
          Sets the point to new coordinates
 void setTo(Point3D point)
          Sets the point to the coordinates of the given point
 void setToCrossProduct(Point3D p1, Point3D p2)
          Sets this point/vector to the result of the cross product of the two specified points/vectors
 void setX(float x)
          Sets the point's x-coordinate to the specified value
 void setY(float y)
          Sets the point's y-coordinate to the specified value
 void setZ(float z)
          Sets the point's z-coordinate to the specified value
 void subtract(float x, float y, float z)
          Subtracts the given parameters from this point
 void subtract(Point3D point)
          Subtracts the specified point from this point
 Point3D subtract(Point3D p1, Point3D p2)
          Subtracts p1 from p2 and returns the result as a Point3D object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Point3D

public Point3D(float x,
               float y,
               float z)
Creates a new point (vertex) in three-dimensional space

Parameters:
x - x-coordinate of the 3D point
y - y-coordinate of the 3D point
z - z-coordinate of the 3D point

Point3D

public Point3D(Point3D point)

Point3D

public Point3D()
Creates a new point (vertex) in three-dimensional space that has the coordinates (0,0,0);

Method Detail

setTo

public void setTo(Point3D point)
Sets the point to the coordinates of the given point

Parameters:
point - point with new coordinates

setTo

public void setTo(float x,
                  float y,
                  float z)
Sets the point to new coordinates

Parameters:
x - new x-coordinate
y - new y-coordinate
z - new z-coordinate

isEqualTo

public boolean isEqualTo(Point3D point)
Checks if this point is equal to the given point. If the coordinates of the two points are the same "true" is returned, else "false".

Parameters:
point -
Returns:
"true" if equal, "false" if not equal

isEqualTo

public boolean isEqualTo(float x,
                         float y,
                         float z)
Checks if this point is equal to the specified coordinates

Parameters:
x - x-coordinate
y - y-coordinate
z - z-coordinate
Returns:
"true" if equal, "false" if not equal

add

public void add(float x,
                float y,
                float z)
Adds the given parameters to this point

Parameters:
x - x-coordinate
y - y-coordinate
z - z-coordinate

add

public void add(Point3D point)
Adds the specified point to this point

Parameters:
point - point to add

subtract

public void subtract(float x,
                     float y,
                     float z)
Subtracts the given parameters from this point

Parameters:
x - x-coordinate
y - y-coordinate
z - z-coordinate

subtract

public void subtract(Point3D point)
Subtracts the specified point from this point

Parameters:
point - point to add

subtract

public Point3D subtract(Point3D p1,
                        Point3D p2)
Subtracts p1 from p2 and returns the result as a Point3D object

Parameters:
p1 - subtrahent
p2 - minuend

multiply

public void multiply(float scalar)
Multiplies the point by the specified scalar

Parameters:
scalar - scalar to multiply by

divide

public void divide(float scalar)
Divides the point by the specified scalar

Parameters:
scalar - scalar to divide by

getLength

public float getLength()
Returns the length of this point (or rather vector)

Returns:
length of the point/vector

getCrossProduct

public Point3D getCrossProduct(Point3D p1,
                               Point3D p2)
Returns the result of the cross product of two points/vectors

Parameters:
p1 - point/vector 1
p2 - point/vector 2
Returns:
cross product of the two points/vectors

getDotProduct

public float getDotProduct(Point3D p1,
                           Point3D p2)
Returns the dot product of the two points/vectors. The dot product is useful to find out whether two vectors are orthogonal to each other, because that is the case, if the dot product is 0.

Parameters:
p1 - point/vector 1
p2 - point/vector 2
Returns:
dot product of the two points

setToCrossProduct

public void setToCrossProduct(Point3D p1,
                              Point3D p2)
Sets this point/vector to the result of the cross product of the two specified points/vectors

Parameters:
p1 - point/vector 1
p2 - point/vector 2

normalize

public void normalize()
Converts this point (or rather vector) to a vector of length 1.


getX

public float getX()
Returns the x-coordinate of the 3D point (vertex)

Returns:
x-coordinate

getY

public float getY()
Returns the y-coordinate of the 3D point (vertex)

Returns:
y-coordinate

getZ

public float getZ()
Returns the z-coordinate of the 3D point (vertex)

Returns:
z-coordinate

setX

public void setX(float x)
Sets the point's x-coordinate to the specified value

Parameters:
x - x-coordinate

setY

public void setY(float y)
Sets the point's y-coordinate to the specified value

Parameters:
y - y-coordinate

setZ

public void setZ(float z)
Sets the point's z-coordinate to the specified value

Parameters:
z - z-coordinate

getPoint

public float[] getPoint()
Returns the point (vertex) with its 3D coordinates (x,y,z)

Returns:
3D point or rather vertex

copy

public Point3D copy()
Returns a copy of this point

Returns:
a copy of this point