net.algart.drawing3d
Class Orientation3D

java.lang.Object
  extended by net.algart.drawing3d.Orientation3D

public final class Orientation3D
extends java.lang.Object

Orthonormal basis in 3D space: 3 orthogonal unit vectors i, j, k (usually describing the orientation of some 3D configuration in the space). Each vector is represented by 3 double values: its components (x,y,z).

This class is immutable and thread-safe: there are no ways to modify settings of the created instance.

AlgART Laboratory 2010

Since:
JDK 1.5
Version:
1.0
Author:
Daniel Alievsky

Field Summary
Modifier and Type Field and Description
static Orientation3D DEFAULT
          Standard orientation: i vector is (1,0,0), j vector is (0,1,0), k vector is (0,0,1).
 
Method Summary
Modifier and Type Method and Description
 boolean equals(java.lang.Object obj)
          Indicates whether some other basis is equal to this instance, that is all corresponding components are absolutely identical.
static Orientation3D getInstance(double ix, double iy, double iz, double jx, double jy, double jz)
          Creates new instance of this class, where the components of i and j vector are specified in the arguments and k vector is chosen automatically as the vector product [i,j] = (iyjzizjy, izjxixjz, ixjyiyjx)
 double getIx()
          Returns x-component ix of i vector in this basis.
 double getIy()
          Returns y-component iy of i vector in this basis.
 double getIz()
          Returns z-component iz of i vector in this basis.
 double getJx()
          Returns x-component jx of j vector in this basis.
 double getJy()
          Returns y-component jy of j vector in this basis.
 double getJz()
          Returns z-component jz of j vector in this basis.
 double getKx()
          Returns x-component kx of k vector in this basis.
 double getKy()
          Returns y-component ky of k vector in this basis.
 double getKz()
          Returns z-component kz of k vector in this basis.
static Orientation3D getSomeInstance(double ix, double iy, double iz)
          Creates new instance of this class, where the components of i vector are specified in the arguments, j and k vectors are chosen automatically by some (undocumented) way, so that the resulting basis i, j, k is orthonormal.
 int hashCode()
          Returns the hash code of this object.
 double inverseTransformX(double x, double y, double z)
          Returns the projection of the given vector (x,y,z) to the vector i.
 double inverseTransformY(double x, double y, double z)
          Returns the projection of the given vector (x,y,z) to the vector j.
 double inverseTransformZ(double x, double y, double z)
          Returns the projection of the given vector (x,y,z) to the vector k.
 Orientation3D rotate(double xAngle, double yAngle, double zAngle)
          Rotates this basis anticlockwise by the angle xAngle (in radians) around x-axis, then by angle yAngle (in radians) around y-axis, then by angle zAngle (in radians) around z-axis, and returns the result.
 Orientation3D rotate(double vX, double vY, double vZ, double angle)
          Rotates this basis by the specified angle (in radians) around the specified vector v=(vx,vyvz) anticlockwise and returns the result.
 Orientation3D rotateI(double angle)
          Rotates this basis by the specified angle (in radians) around i vector anticlockwise and returns the result.
 Orientation3D rotateJ(double angle)
          Rotates this basis by the specified angle (in radians) around j vector anticlockwise and returns the result.
 Orientation3D rotateK(double angle)
          Rotates this basis by the specified angle (in radians) around k vector anticlockwise and returns the result.
 Orientation3D superposition(Orientation3D basis)
          Returns new basis, consisting of 3 vectors i''=ixi'+iyj'+izk', j''=jxi'+jyj'+jzk', k''=kxi'+kyj'+kzk', where i=(ix,iy,iz), j=(jx,jy,jz) and k=(kx,ky,kz) is this basis and i', j', k' is a basis, specified in the argument.
 java.lang.String toString()
          Returns a brief string description of this object.
 double transformX(double x, double y, double z)
          Returns x-component of the vector xi+yj+zk.
 double transformY(double x, double y, double z)
          Returns y-component of the vector xi+yj+zk.
 double transformZ(double x, double y, double z)
          Returns z-component of the vector xi+yj+zk.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final Orientation3D DEFAULT
Standard orientation: i vector is (1,0,0), j vector is (0,1,0), k vector is (0,0,1).

Method Detail

getSomeInstance

public static Orientation3D getSomeInstance(double ix,
                                            double iy,
                                            double iz)
Creates new instance of this class, where the components of i vector are specified in the arguments, j and k vectors are chosen automatically by some (undocumented) way, so that the resulting basis i, j, k is orthonormal.

If the passed vector i=(ix,iy,iz) is not unit, it is automatically normalized: these 3 numbers are divided by Math.sqrt(ix²+iy²+iz²).

Parameters:
ix - x-component ix of i vector in the created basis.
iy - y-component iy of i vector in the created basis.
iz - z-component iz of i vector in the created basis.
Returns:
new orthonormal basis in 3D space with the given i vector.

getInstance

public static Orientation3D getInstance(double ix,
                                        double iy,
                                        double iz,
                                        double jx,
                                        double jy,
                                        double jz)
Creates new instance of this class, where the components of i and j vector are specified in the arguments and k vector is chosen automatically as the vector product [i,j] = (iyjzizjy, izjxixjz, ixjyiyjx)

If the passed vector i=(ix,iy,iz) is not unit, it is automatically normalized: these 3 numbers are divided by Math.sqrt(ix²+iy²+iz²). If the passed vector j=(jx,jy,jz) is not unit, it is automatically normalized: these 3 numbers are divided by Math.sqrt(jx²+jy²+jz²). If the passed i and j vectors are not orthogonal, j vector is automatically corrected to become orthogonal to i.

Parameters:
ix - x-component ix of i vector in the created basis.
iy - y-component iy of i vector in the created basis.
iz - z-component iz of i vector in the created basis.
jx - x-component jx of j vector in the created basis.
jy - y-component jy of j vector in the created basis.
jz - z-component jz of j vector in the created basis.
Returns:
new orthonormal basis in 3D space with the given i and j vectors.

getIx

public double getIx()
Returns x-component ix of i vector in this basis.

Returns:
x-component ix of i vector in this basis.

getIy

public double getIy()
Returns y-component iy of i vector in this basis.

Returns:
y-component iy of i vector in this basis.

getIz

public double getIz()
Returns z-component iz of i vector in this basis.

Returns:
z-component iz of i vector in this basis.

getJx

public double getJx()
Returns x-component jx of j vector in this basis.

Returns:
x-component jx of j vector in this basis.

getJy

public double getJy()
Returns y-component jy of j vector in this basis.

Returns:
y-component jy of j vector in this basis.

getJz

public double getJz()
Returns z-component jz of j vector in this basis.

Returns:
z-component jz of j vector in this basis.

getKx

public double getKx()
Returns x-component kx of k vector in this basis.

Returns:
x-component kx of k vector in this basis.

getKy

public double getKy()
Returns y-component ky of k vector in this basis.

Returns:
y-component ky of k vector in this basis.

getKz

public double getKz()
Returns z-component kz of k vector in this basis.

Returns:
z-component kz of k vector in this basis.

transformX

public double transformX(double x,
                         double y,
                         double z)
Returns x-component of the vector xi+yj+zk. In other words, returns xix+yjx+zkx.

Parameters:
x - x-component of some vector, specified in the given basis.
y - y-component of some vector, specified in the given basis.
z - z-component of some vector, specified in the given basis.
Returns:
x-component of the vector xi+yj+zk.

transformY

public double transformY(double x,
                         double y,
                         double z)
Returns y-component of the vector xi+yj+zk. In other words, returns xiy+yjy+zky.

Parameters:
x - x-component of some vector, specified in the given basis.
y - y-component of some vector, specified in the given basis.
z - z-component of some vector, specified in the given basis.
Returns:
y-component of the vector xi+yj+zk.

transformZ

public double transformZ(double x,
                         double y,
                         double z)
Returns z-component of the vector xi+yj+zk. In other words, returns xiz+yjz+zkz.

Parameters:
x - x-component of some vector, specified in the given basis.
y - y-component of some vector, specified in the given basis.
z - z-component of some vector, specified in the given basis.
Returns:
z-component of the vector xi+yj+zk.

inverseTransformX

public double inverseTransformX(double x,
                                double y,
                                double z)
Returns the projection of the given vector (x,y,z) to the vector i. In other words, returns xix+yiy+ziz: the x-components of the given vector in terms of this basis.

Parameters:
x - x-component of some vector.
y - y-component of some vector.
z - z-component of some vector.
Returns:
the x-components of the given vector in terms of this basis.

inverseTransformY

public double inverseTransformY(double x,
                                double y,
                                double z)
Returns the projection of the given vector (x,y,z) to the vector j. In other words, returns xjx+yjy+zjz: the y-components of the given vector in terms of this basis.

Parameters:
x - x-component of some vector.
y - y-component of some vector.
z - z-component of some vector.
Returns:
the y-components of the given vector in terms of this basis.

inverseTransformZ

public double inverseTransformZ(double x,
                                double y,
                                double z)
Returns the projection of the given vector (x,y,z) to the vector k. In other words, returns xkx+yky+zkz: the z-components of the given vector in terms of this basis.

Parameters:
x - x-component of some vector.
y - y-component of some vector.
z - z-component of some vector.
Returns:
the z-components of the given vector in terms of this basis.

superposition

public Orientation3D superposition(Orientation3D basis)
Returns new basis, consisting of 3 vectors i''=ixi'+iyj'+izk', j''=jxi'+jyj'+jzk', k''=kxi'+kyj'+kzk', where i=(ix,iy,iz), j=(jx,jy,jz) and k=(kx,ky,kz) is this basis and i', j', k' is a basis, specified in the argument. If we'll interpret this and passed bases as rotations of the coordinate system from default basis to i, j, k triplet, then this method describes the composition of the passed and this rotations.

Parameters:
basis - some other basis.
Returns:
this basis, transformed according the passed one.
Throws:
java.lang.NullPointerException - if the argument is null.

rotateI

public Orientation3D rotateI(double angle)
Rotates this basis by the specified angle (in radians) around i vector anticlockwise and returns the result. The returned basis has the same i vector. "Anticlockwise" means, that if, for example, angle=Math.PI/2, then j of the result will be equal to k vector of this basis.

Parameters:
angle - angle for rotation around i vector, in radians.
Returns:
the rotated basis.

rotateJ

public Orientation3D rotateJ(double angle)
Rotates this basis by the specified angle (in radians) around j vector anticlockwise and returns the result. The returned basis has the same j vector. "Anticlockwise" means, that if, for example, angle=Math.PI/2, then k of the result will be equal to i vector of this basis.

Parameters:
angle - angle for rotation around j vector, in radians.
Returns:
the rotated basis.

rotateK

public Orientation3D rotateK(double angle)
Rotates this basis by the specified angle (in radians) around k vector anticlockwise and returns the result. The returned basis has the same k vector. "Anticlockwise" means, that if, for example, angle=Math.PI/2, then i of the result will be equal to j vector of this basis.

Parameters:
angle - angle for rotation around k vector, in radians.
Returns:
the rotated basis.

rotate

public Orientation3D rotate(double xAngle,
                            double yAngle,
                            double zAngle)
Rotates this basis anticlockwise by the angle xAngle (in radians) around x-axis, then by angle yAngle (in radians) around y-axis, then by angle zAngle (in radians) around z-axis, and returns the result. "Anticlockwise" rotation around x axis means, that if, for example, xAngle=Math.PI/2, then (0,1,0) vector is transformed to (0,0,1). Analogously, "anticlockwise" rotation around y axis means, that if yAngle=Math.PI/2, then (0,0,1) vector is transformed to (1,0,0), and "anticlockwise" rotation around z axis means, that if zAngle=Math.PI/2, then (1,0,0) vector is transformed to (0,1,0).

Parameters:
xAngle - angle for rotation around x-axis, in radians.
yAngle - angle for rotation around y-axis, in radians.
zAngle - angle for rotation around z-axis, in radians.
Returns:
the rotated basis.

rotate

public Orientation3D rotate(double vX,
                            double vY,
                            double vZ,
                            double angle)
Rotates this basis by the specified angle (in radians) around the specified vector v=(vx,vyvz) anticlockwise and returns the result. "Anticlockwise" means, that if (vX,vY,vZ) is i, then this method is equivalent to rotateI(angle).

Parameters:
vX - x-component of v vector.
vY - y-component of v vector.
vZ - z-component of v vector.
angle - angle for rotation around v vector, in radians.
Returns:
the rotated basis.

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.

hashCode

public int hashCode()
Returns the hash code of this object. The result depends on all components of the basis vectors i, j, k.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of this object.

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other basis is equal to this instance, that is all corresponding components are absolutely identical.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to be compared for equality with this instance.
Returns:
true if the specified object is a basis equal to this one.