de.grogra.vecmath.geom
Class TransformableVolume

java.lang.Object
  extended by de.grogra.vecmath.geom.VolumeBase
      extended by de.grogra.vecmath.geom.TransformableVolume
All Implemented Interfaces:
Volume
Direct Known Subclasses:
Cube, FrustumBase, HalfSpace, ImplicitVolume, SensorDisc, SkySphere, Sphere, Square

public abstract class TransformableVolume
extends VolumeBase

This class represents the base class for volumes whose geometry is specified in local coordinates. The transformation from global world coordinates to local object coordinates is stored in the fields m00 to m22 and t0 to t2, the transformation is computed by

oi = ∑i mi,j (wj - tj)
I.e., the vector t represents the location of the object origin in world coordinates. This representation has been chosen instead of an instance of Matrix4d for memory and speed (faster instantiation) reasons. After modification of matrix components and other geometric parameters declared by subclasses, invalidate() has to be invoked.

Author:
Ole Kniemeyer

Field Summary
protected  double m00
          00-component of the rotation matrix from world coordinates to object coordinates.
protected  double m01
          01-component of the rotation matrix from world coordinates to object coordinates.
protected  double m02
          02-component of the rotation matrix from world coordinates to object coordinates.
protected  double m10
          10-component of the rotation matrix from world coordinates to object coordinates.
protected  double m11
          11-component of the rotation matrix from world coordinates to object coordinates.
protected  double m12
          12-component of the rotation matrix from world coordinates to object coordinates.
protected  double m20
          20-component of the rotation matrix from world coordinates to object coordinates.
protected  double m21
          21-component of the rotation matrix from world coordinates to object coordinates.
protected  double m22
          22-component of the rotation matrix from world coordinates to object coordinates.
protected  double t0
          0-component of the translation from object coordinates to world coordinates.
protected  double t1
          1-component of the translation from object coordinates to world coordinates.
protected  double t2
          2-component of the translation from object coordinates to world coordinates.
 
Constructor Summary
TransformableVolume()
           
 
Method Summary
 void getDiscExtent(double z, double radius, Tuple3d min, Tuple3d max)
           
 void getDiscsExtent(double z1, double radius1, double z2, double radius2, Tuple3d min, Tuple3d max)
           
 double getFrobeniusNorm()
          Returns the Frobenius norm of the upper 3x3 values of the world-to-object transformation, i.e., the square root of m00 * m00 + ... + m22 * m22.
 Matrix3d getObjectToWorldRotationScale()
          Computes the rotational component of the transformation from local object coordinates to global world coordinates.
 void getTransformation(Matrix3d rot, Tuple3d trans)
          gets the transformation from world to object coordinates to the specified matrix and vector: o = rot * (w - trans)
 void invalidate()
          Invalidates cached information about this volume.
 void invTransformPoint(Tuple3d in, Tuple3d out)
          Transforms the point in, specified in local object coordinates, to out in global world coordinates.
 void scale(double sx, double sy, double sz)
          Multiplies the current world-to-object transformation from left by a scaling matrix.
 void setTransformation(Matrix3d rot, Tuple3d trans)
          Sets the transformation from world to object coordinates to the specified matrix and vector: o = rot * (w - trans)
 void setTransformation(Tuple3d origin, Tuple3d axis)
          Sets the transformation from world to object coordinates to an orthonormal transformation which transforms the origin point to (0,0,0) and the normalized axis vector to (0,0,1).
 void transformPoint(Tuple3d in, Tuple3d out)
          Transforms the point in, specified in global world coordinates, to out in local object coordinates.
 void transformTranspose(Tuple3d in, Tuple3d out)
          Multiplies the vector in by the transpose of the upper 3x3 values of the world-to-object transformation and stores the result in out.
 void transformVector(Tuple3d in, Tuple3d out)
          Transforms the direction in, specified in global world coordinates, to out in local object coordinates.
 void translate(double dx, double dy, double dz)
          Multiplies the current world-to-object transformation from right by a translation matrix using the negated values.
 
Methods inherited from class de.grogra.vecmath.geom.VolumeBase
addConvexIntersections, getId, operator$and, operator$com, operator$or, operator$sub, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.grogra.vecmath.geom.Volume
boxContainsBoundary, computeIntersections, computeNormal, computeTangents, computeUV, contains, getExtent
 

Field Detail

m00

protected double m00
00-component of the rotation matrix from world coordinates to object coordinates.


m01

protected double m01
01-component of the rotation matrix from world coordinates to object coordinates.


m02

protected double m02
02-component of the rotation matrix from world coordinates to object coordinates.


m10

protected double m10
10-component of the rotation matrix from world coordinates to object coordinates.


m11

protected double m11
11-component of the rotation matrix from world coordinates to object coordinates.


m12

protected double m12
12-component of the rotation matrix from world coordinates to object coordinates.


m20

protected double m20
20-component of the rotation matrix from world coordinates to object coordinates.


m21

protected double m21
21-component of the rotation matrix from world coordinates to object coordinates.


m22

protected double m22
22-component of the rotation matrix from world coordinates to object coordinates.


t0

protected double t0
0-component of the translation from object coordinates to world coordinates.


t1

protected double t1
1-component of the translation from object coordinates to world coordinates.


t2

protected double t2
2-component of the translation from object coordinates to world coordinates.

Constructor Detail

TransformableVolume

public TransformableVolume()
Method Detail

getDiscExtent

public void getDiscExtent(double z,
                          double radius,
                          Tuple3d min,
                          Tuple3d max)

getDiscsExtent

public void getDiscsExtent(double z1,
                           double radius1,
                           double z2,
                           double radius2,
                           Tuple3d min,
                           Tuple3d max)

getFrobeniusNorm

public double getFrobeniusNorm()
Returns the Frobenius norm of the upper 3x3 values of the world-to-object transformation, i.e., the square root of m00 * m00 + ... + m22 * m22. Note that the length of a vector in object coordinates is less than or equal to the length of this vector in world coordinates multplied by the Frobenius norm of the transformation.

Returns:
Frobenius norm of world-to-object transformation

getObjectToWorldRotationScale

public Matrix3d getObjectToWorldRotationScale()
Computes the rotational component of the transformation from local object coordinates to global world coordinates. The matrix components of the returned value must not be modified.

Returns:
object-to-world transformation

getTransformation

public void getTransformation(Matrix3d rot,
                              Tuple3d trans)
gets the transformation from world to object coordinates to the specified matrix and vector: o = rot * (w - trans)

Parameters:
rot - rotational component is stored in rot
trans - translational component is stored in trans

invalidate

public void invalidate()
Invalidates cached information about this volume. This method has to be invoked after matrix components and geometric parameters declared by subclasses have been changed.


invTransformPoint

public void invTransformPoint(Tuple3d in,
                              Tuple3d out)
Transforms the point in, specified in local object coordinates, to out in global world coordinates. in and out may be the same instance.

Parameters:
in - point in object coordinates
out - point in world coordinates

scale

public void scale(double sx,
                  double sy,
                  double sz)
Multiplies the current world-to-object transformation from left by a scaling matrix. This corresponds to a scaling of the object by the reciprocal of the specified values.

Parameters:
sx - scaling factor in x-direction
sy - scaling factor in y-direction
sz - scaling factor in z-direction

setTransformation

public void setTransformation(Matrix3d rot,
                              Tuple3d trans)
Sets the transformation from world to object coordinates to the specified matrix and vector: o = rot * (w - trans)

Parameters:
rot - rotational component of new transformation
trans - translational component of new transformation

setTransformation

public void setTransformation(Tuple3d origin,
                              Tuple3d axis)
Sets the transformation from world to object coordinates to an orthonormal transformation which transforms the origin point to (0,0,0) and the normalized axis vector to (0,0,1).

Parameters:
origin - origin in world coordinates
axis - axis (local z-direction) in world coordinates

transformPoint

public void transformPoint(Tuple3d in,
                           Tuple3d out)
Transforms the point in, specified in global world coordinates, to out in local object coordinates. in and out may be the same instance.

Parameters:
in - point in world coordinates
out - point in object coordinates

transformTranspose

public void transformTranspose(Tuple3d in,
                               Tuple3d out)
Multiplies the vector in by the transpose of the upper 3x3 values of the world-to-object transformation and stores the result in out. This can be used to transform normal vectors from object coordinates to world coordinates. in and out may be the same instance.

Parameters:
in - direction in world coordinates
out - direction in object coordinates

transformVector

public void transformVector(Tuple3d in,
                            Tuple3d out)
Transforms the direction in, specified in global world coordinates, to out in local object coordinates. in and out may be the same instance.

Parameters:
in - direction in world coordinates
out - direction in object coordinates

translate

public void translate(double dx,
                      double dy,
                      double dz)
Multiplies the current world-to-object transformation from right by a translation matrix using the negated values. This corresponds to a translation of the object in the world by the specified values.

Parameters:
dx - translation in x-direction
dy - translation in y-direction
dz - translation in z-direction