net.algart.drawing3d
Class CoordinateSystem3D

java.lang.Object
  extended by net.algart.drawing3d.CoordinateSystem3D
All Implemented Interfaces:
java.lang.Cloneable

public final class CoordinateSystem3D
extends java.lang.Object
implements java.lang.Cloneable

Coordinate system in 3D space. Formally, it is a triplet of orthogonal vectors, named the basis, having the same length, named the scale σ, and originating in 3D space from the same point, named the origin O=(Ox,Oy,Oz).

The base vectors, divided by the scale σ, are named the orientation and represented by Orientation3D class: the triplet of orthonormal vectors (i, j, k). So, the basis consists of 3 vectors i, σj, σk), originating from O point.

The coordinates of the origin O, the scale σ and the orientation (i, j, k) are passed to the constructor and can be gotten and set or get at any time by the access methods. The scale σ cannot be zero or negative.

The main goal of this class is transforming coordinates of some point from this coordinate system to the simple coordinates and vice versa. Formally, this class defines:

  1. the direct transform of some point P, having coordinates (x,y,z) in terms of the coordinate system, represented by this class — i.e. P = O + σ(xi+yj+zk) — to the coordinates in the basic coordinate system
        x' = Ox + σ(xix+yjx+zkx),
        y' = Oy + σ(xiy+yjy+zky),
        z' = Oz + σ(xiz+yjz+zkz);
  2. the inverse transform of the coordinates (x',y',z') of the point P, specified in terms of the basic coordinate system, to the coordinates (x,y,z) in terms of the coordinate system, represented by this class.

The direct transform is performed by

methods, the inverse transform is performed by

methods.

This class is not thread-safe, but is thread-compatible and can be synchronized manually if multithread access is necessary.

AlgART Laboratory 2010

Since:
JDK 1.5
Version:
1.0
Author:
Daniel Alievsky

Constructor Summary
Constructor and Description
CoordinateSystem3D()
          Creates the trivial coordinate system: O=0=(0,0,0), σ=1.0, i vector is (1,0,0), j vector is (0,1,0), k vector is (0,0,1).
CoordinateSystem3D(double originX, double originY, double originZ, double scale, Orientation3D orientation)
          Creates new coordinate system, fully specified by the arguments of the constructor.
 
Method Summary
Modifier and Type Method and Description
 CoordinateSystem3D clone()
          Returns the precise clone of this coordinate system.
 Orientation3D getOrientation()
          Returns the orientation: the orthonormal basis (i, j, k).
 double getOriginX()
          Returns x-coordinate of the origin Ox.
 double getOriginY()
          Returns y-coordinate of the origin Oy.
 double getOriginZ()
          Returns z-coordinate of the origin Oz.
 double getScale()
          Returns the scale σ.
 double inverseTransformX(double x, double y, double z)
          Returns the x-coordinate of the given point in terms of this coordinate system.
 double inverseTransformY(double x, double y, double z)
          Returns the y-coordinate of the given point in terms of this coordinate system.
 double inverseTransformZ(double x, double y, double z)
          Returns the z-coordinate of the given point in terms of this coordinate system.
 void setOrientation(Orientation3D orientation)
          Sets the new orientation: the orthonormal basis (i, j, k).
 void setOrigin(double originX, double originY, double originZ)
          Sets the new origin O.
 void setScale(double scale)
          Sets the scale σ.
 java.lang.String toString()
          Returns a brief string description of this object.
 double transformX(double x, double y, double z)
          Returns the x-coordinate of the point, which has the given coordinates in terms of this coordinate system.
 double transformY(double x, double y, double z)
          Returns the y-coordinate of the point, which has the given coordinates in terms of this coordinate system.
 double transformZ(double x, double y, double z)
          Returns the z-coordinate of the point, which has the given coordinates in terms of this coordinate system.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CoordinateSystem3D

public CoordinateSystem3D()
Creates the trivial coordinate system: O=0=(0,0,0), σ=1.0, i vector is (1,0,0), j vector is (0,1,0), k vector is (0,0,1).


CoordinateSystem3D

public CoordinateSystem3D(double originX,
                          double originY,
                          double originZ,
                          double scale,
                          Orientation3D orientation)
Creates new coordinate system, fully specified by the arguments of the constructor.

Parameters:
originX - x-coordinate of the origin Ox.
originY - y-coordinate of the origin Oy.
originZ - z-coordinate of the origin Oz.
scale - the scale σ.
orientation - the orientation (i, j, k).
Throws:
java.lang.NullPointerException - if orientation argument if null.
java.lang.IllegalArgumentException - if scale<=0.0.
Method Detail

getOriginX

public double getOriginX()
Returns x-coordinate of the origin Ox.

Returns:
x-coordinate of the origin Ox.

getOriginY

public double getOriginY()
Returns y-coordinate of the origin Oy.

Returns:
y-coordinate of the origin Oy.

getOriginZ

public double getOriginZ()
Returns z-coordinate of the origin Oz.

Returns:
z-coordinate of the origin Oz.

setOrigin

public void setOrigin(double originX,
                      double originY,
                      double originZ)
Sets the new origin O.

Parameters:
originX - x-coordinate of the new origin Ox.
originY - y-coordinate of the new origin Oy.
originZ - z-coordinate of the new origin Oz.

getScale

public double getScale()
Returns the scale σ.

Returns:
the scale σ.

setScale

public void setScale(double scale)
Sets the scale σ.

Parameters:
scale - the new scale σ.
Throws:
java.lang.IllegalArgumentException - if scale<=0.0.

getOrientation

public Orientation3D getOrientation()
Returns the orientation: the orthonormal basis (i, j, k).

Returns:
the orientation.

setOrientation

public void setOrientation(Orientation3D orientation)
Sets the new orientation: the orthonormal basis (i, j, k).

Parameters:
orientation - the new orientation.

transformX

public double transformX(double x,
                         double y,
                         double z)
Returns the x-coordinate of the point, which has the given coordinates in terms of this coordinate system. In other words, returns x' = Ox + σ(xix+yjx+zkx), where x,y,z are the arguments of this method.

Parameters:
x - the x-coordinate in terms of the coordinate system, represented by this class.
y - the y-coordinate in terms of the coordinate system, represented by this class.
z - the z-coordinate in terms of the coordinate system, represented by this class.
Returns:
the x-coordinate of this point in terms of the basic coordinate system.

transformY

public double transformY(double x,
                         double y,
                         double z)
Returns the y-coordinate of the point, which has the given coordinates in terms of this coordinate system. In other words, returns y' = Oy + σ(xiy+yjy+zky), where x,y,z are the arguments of this method.

Parameters:
x - the x-coordinate in terms of the coordinate system, represented by this class.
y - the y-coordinate in terms of the coordinate system, represented by this class.
z - the z-coordinate in terms of the coordinate system, represented by this class.
Returns:
the y-coordinate of this point in terms of the basic coordinate system.

transformZ

public double transformZ(double x,
                         double y,
                         double z)
Returns the z-coordinate of the point, which has the given coordinates in terms of this coordinate system. In other words, returns z' = Oz + σ(xiz+yjz+zkz), where x,y,z are the arguments of this method.

Parameters:
x - the x-coordinate in terms of the coordinate system, represented by this class.
y - the y-coordinate in terms of the coordinate system, represented by this class.
z - the z-coordinate in terms of the coordinate system, represented by this class.
Returns:
the z-coordinate of this point in terms of the basic coordinate system.

inverseTransformX

public double inverseTransformX(double x,
                                double y,
                                double z)
Returns the x-coordinate of the given point in terms of this coordinate system. In other words, returns x = ((x'−Ox)ix + (y'−Oy)iy + (z'−Oz)iz) / σ, where x',y',z' are the arguments of this method.

Parameters:
x - the x-coordinate of some point.
y - the y-coordinate of some point.
z - the z-coordinate of some point.
Returns:
the x-coordinate of this point in terms of the coordinate system, represented by this class.

inverseTransformY

public double inverseTransformY(double x,
                                double y,
                                double z)
Returns the y-coordinate of the given point in terms of this coordinate system. In other words, returns y = ((x'−Ox)jx + (y'−Oy)jy + (z'−Oz)jz) / σ, where x',y',z' are the arguments of this method.

Parameters:
x - the x-coordinate of some point.
y - the y-coordinate of some point.
z - the z-coordinate of some point.
Returns:
the y-coordinate of this point in terms of the coordinate system, represented by this class.

inverseTransformZ

public double inverseTransformZ(double x,
                                double y,
                                double z)
Returns the z-coordinate of the given point in terms of this coordinate system. In other words, returns z = ((x'−Ox)kx + (y'−Oy)ky + (z'−Oz)kz) / σ, where x',y',z' are the arguments of this method.

Parameters:
x - the x-coordinate of some point.
y - the y-coordinate of some point.
z - the z-coordinate of some point.
Returns:
the z-coordinate of this point in terms of the coordinate system, represented by this class.

clone

public CoordinateSystem3D clone()
Returns the precise clone of this coordinate system.

Overrides:
clone in class java.lang.Object
Returns:
the precise clone of this coordinate system.

toString

public java.lang.String toString()
Returns a brief string description of this object.

The result of this method may depend on implementation.

Overrides:
toString in class java.lang.Object
Returns:
a brief string description of this object.