artofillusion.math
Class CoordinateSystem

java.lang.Object
  extended by artofillusion.math.CoordinateSystem

public class CoordinateSystem
extends java.lang.Object

The CoordinateSystem class describes the position and orientation of one coordinate system relative to another one. It is defined by three vectors. orig defines the position of the origin of the new coordinate system, while zdir and updir define the directions of the z and y axes, respectively. (Note that the y axis will only be parallel to updir in the special case that zdir and updir are perpendicular to each other.) Alternatively, the orientation can be represented by three rotation angles about the (global) x, y, and z axes. Both representations are maintained internally.


Constructor Summary
CoordinateSystem()
          Create a new CoordinateSystem which represents an identity transformation (i.e.
CoordinateSystem(java.io.DataInputStream in)
          Create a CoordinateSystem by reading the information that was written by writeToFile().
CoordinateSystem(Vec3 orig, double x, double y, double z)
          Create a new coordinate system.
CoordinateSystem(Vec3 orig, Vec3 zdir, Vec3 updir)
          Create a new coordinate system.
 
Method Summary
 void copyCoords(CoordinateSystem c)
          Make this CoordianteSystem identical to another one.
 CoordinateSystem duplicate()
          Create an exact duplicate of this CoordinateSystem.
 boolean equals(java.lang.Object coords)
          Determine whether this coordinate system is identical to another one.
 Mat4 fromLocal()
          Return a matrix which will transform points from this coordinate system to the outside coordinate system with respect to which it is defined.
 double getAxisAngleRotation(Vec3 axis)
          A rotation can also be described by specifying a rotation axis, and a rotation angle about that axis.
 Vec3 getOrigin()
          Get the origin of this CoordinateSystem.
 double[] getRotationAngles()
          Return the x, y, and z rotation angles.
 Vec3 getUpDirection()
          Get the vector used to define "up" in this CoordinateSystem (usually but not always the y axis direction).
 Vec3 getZDirection()
          Get this CoordinateSystem's z axis direction.
 void setOrientation(double x, double y, double z)
          Set the orientation of this CoordinateSystem.
 void setOrientation(Vec3 zdir, Vec3 updir)
          Set the orientation of this CoordinateSystem.
 void setOrigin(Vec3 orig)
          Set the position of this CoordinateSystem's origin.
 Mat4 toLocal()
          Return a matrix which will transform points from the outside coordinate system to this local coordinate system.
 void transformAxes(Mat4 m)
          Transform this CoordinateSystem's orientation by applying a matrix to its axis directions.
 void transformCoordinates(Mat4 m)
          Transform this CoordinateSystem's position and orientation by applying a matrix to its origin and axis directions.
 void transformOrigin(Mat4 m)
          Transform this CoordinateSystem's position by applying a matrix to its origin.
 void writeToFile(java.io.DataOutputStream out)
          Write out a serialized representation of this CoordinateSystem.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinateSystem

public CoordinateSystem()
Create a new CoordinateSystem which represents an identity transformation (i.e. no translation or rotation).


CoordinateSystem

public CoordinateSystem(Vec3 orig,
                        Vec3 zdir,
                        Vec3 updir)
Create a new coordinate system.

Parameters:
orig - the origin of the new coordinate system
zdir - the direction of the new coordinate system's z axis
updir - defines the "up" direction. If this is perpendicular to zdir, this will be the y axis direction of the new coordinate system.

CoordinateSystem

public CoordinateSystem(Vec3 orig,
                        double x,
                        double y,
                        double z)
Create a new coordinate system.

Parameters:
orig - the origin of the new coordinate system
x - the rotation angle around the x axis
y - the rotation angle around the y axis
z - the rotation angle around the z axis

CoordinateSystem

public CoordinateSystem(java.io.DataInputStream in)
                 throws java.io.IOException
Create a CoordinateSystem by reading the information that was written by writeToFile().

Throws:
java.io.IOException
Method Detail

duplicate

public final CoordinateSystem duplicate()
Create an exact duplicate of this CoordinateSystem.


copyCoords

public final void copyCoords(CoordinateSystem c)
Make this CoordianteSystem identical to another one.


equals

public final boolean equals(java.lang.Object coords)
Determine whether this coordinate system is identical to another one.

Overrides:
equals in class java.lang.Object

setOrigin

public final void setOrigin(Vec3 orig)
Set the position of this CoordinateSystem's origin.


setOrientation

public final void setOrientation(Vec3 zdir,
                                 Vec3 updir)
Set the orientation of this CoordinateSystem.

Parameters:
zdir - the direction of this coordinate system's z axis
updir - defines the "up" direction. If this is perpendicular to zdir, this will become the y axis direction.

setOrientation

public final void setOrientation(double x,
                                 double y,
                                 double z)
Set the orientation of this CoordinateSystem.

Parameters:
x - the rotation angle around the x axis
y - the rotation angle around the y axis
z - the rotation angle around the z axis

getOrigin

public final Vec3 getOrigin()
Get the origin of this CoordinateSystem.


getZDirection

public final Vec3 getZDirection()
Get this CoordinateSystem's z axis direction.


getUpDirection

public final Vec3 getUpDirection()
Get the vector used to define "up" in this CoordinateSystem (usually but not always the y axis direction).


getRotationAngles

public final double[] getRotationAngles()
Return the x, y, and z rotation angles.


transformAxes

public final void transformAxes(Mat4 m)
Transform this CoordinateSystem's orientation by applying a matrix to its axis directions.


transformOrigin

public final void transformOrigin(Mat4 m)
Transform this CoordinateSystem's position by applying a matrix to its origin.


transformCoordinates

public final void transformCoordinates(Mat4 m)
Transform this CoordinateSystem's position and orientation by applying a matrix to its origin and axis directions.


fromLocal

public final Mat4 fromLocal()
Return a matrix which will transform points from this coordinate system to the outside coordinate system with respect to which it is defined.


toLocal

public final Mat4 toLocal()
Return a matrix which will transform points from the outside coordinate system to this local coordinate system.


getAxisAngleRotation

public final double getAxisAngleRotation(Vec3 axis)
A rotation can also be described by specifying a rotation axis, and a rotation angle about that axis. This method calculates this alternate representation of the to-local rotation. The from-local transformation is found by simply reversing the sign of the rotation angle. It returns the rotation angle, and overwrites axis with a unit vector along the rotation axis.


writeToFile

public void writeToFile(java.io.DataOutputStream out)
                 throws java.io.IOException
Write out a serialized representation of this CoordinateSystem.

Throws:
java.io.IOException


Copyright © 1999-2011 by Peter Eastman.