FreeHEP API
Version current

org.freehep.graphics3d
Class Transform3D

java.lang.Object
  extended byorg.freehep.graphics3d.Transform3D
All Implemented Interfaces:
Serializable

public class Transform3D
extends Object
implements Serializable

Taken from Graphics Gems (page 476 and 770).

Version:
$Id: Transform3D.java,v 1.6 2003/03/20 00:20:23 duns Exp $
Author:
Mark Donszelmann
See Also:
Serialized Form
Source Code:
Transform3D.java

Field Summary
protected  Matrix4 m
           
protected  Stack transforms
           
protected  boolean valid
           
 
Constructor Summary
Transform3D()
           
 
Method Summary
 Vector3 deltaInverseTransform(double du, double dv, double dw, Vector3 dxyz)
          returns the world distance of a pixel distance by applying the inverse transform, but without using the translation part
 boolean equals(Object object)
           
 void frustum(double left, double right, double bottom, double top, double near, double far)
          Creates a perspective projection.
 double[][] get(double[] x, double[] y, double[] z, double[][] result)
          Transforms array of points into double array.
 double[] get(double x, double y, double z, double[] result)
          Transforms point into double array.
 double[] get(double x, double y, double z, double x0, double y0, double width, double height, double[] result)
          Applies matrix transform and viewport functions.
 double[][] get(Polyline3 poly, double[][] result)
          Transforms Polyline3 into double array.
 int[][] get(Polyline3 poly, int x0, int y0, int width, int height, int[][] result)
          Applies matrix transform and viewport functions.
 Matrix4 getMatrix()
          Returns current transform.
 Vector3 getTranslate(Vector3 v)
           
 double getU(double x, double y, double z)
          Return U coordinate.
 double getV(double x, double y, double z)
          Return V coordinate.
 double getW(double x, double y, double z)
          Return W coordinate.
 int hashCode()
           
 void multiply(Matrix4 matrix)
          Multiply transform matrix by matrix.
 void ortho(double left, double right, double bottom, double top, double near, double far)
          Creates a parallel projection.
 void pop()
          Pops the top transform off the stack.
 void push()
          Pushes a copy of this transform on the stack.
 void rotate(double ux, double uy, double uz, double theta)
          Rotates over unit vector ux,uy,uz by angle theta (in radiants).
 void scale(double sx, double sy, double sz)
          Scales the model non-uniformly along the x, y and z-axes.
 void setMatrix(Matrix4 matrix)
          Set transform matrix to matrix.
 String toString()
           
 void translate(double tx, double ty, double tz)
           
 void translateModel(double tx, double ty, double tz)
          Translates the current transform.
protected  void validate()
          Validates the current transform and extracts its parameters.
 void zoom(double sx, double sy, double sz)
          Zooms the user non-uniformly along the x, y and z-axes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

transforms

protected Stack transforms

m

protected Matrix4 m

valid

protected boolean valid
Constructor Detail

Transform3D

public Transform3D()
Method Detail

push

public void push()
Pushes a copy of this transform on the stack.


pop

public void pop()
Pops the top transform off the stack.


get

public double[] get(double x,
                    double y,
                    double z,
                    double x0,
                    double y0,
                    double width,
                    double height,
                    double[] result)
Applies matrix transform and viewport functions.
      xw = (xn + 1) * width / 2 + x0;
      yw = height - (yn + 1) * height / 2 + y0;
 

Returns:
transformed point into int[2] using viewport parameters

get

public int[][] get(Polyline3 poly,
                   int x0,
                   int y0,
                   int width,
                   int height,
                   int[][] result)
Applies matrix transform and viewport functions.
      xw = (xn + 1) * width / 2 + x0;
      yw = height - (yn + 1) * height / 2 + y0;
 

Returns:
transformed Polyline3 into int[2][n] using viewport parameters

get

public double[][] get(Polyline3 poly,
                      double[][] result)
Transforms Polyline3 into double array.

Returns:
transformed Polyline3 into double[3][n]

get

public double[][] get(double[] x,
                      double[] y,
                      double[] z,
                      double[][] result)
Transforms array of points into double array.

Returns:
transformed array of points in double[3][n]

get

public double[] get(double x,
                    double y,
                    double z,
                    double[] result)
Transforms point into double array.

Returns:
transformed point in double[3]

getU

public double getU(double x,
                   double y,
                   double z)
Return U coordinate.

Returns:
U coordinate after transformation

getV

public double getV(double x,
                   double y,
                   double z)
Return V coordinate.

Returns:
V coordinate after transformation

getW

public double getW(double x,
                   double y,
                   double z)
Return W coordinate.

Returns:
W coordinate after transformation

deltaInverseTransform

public Vector3 deltaInverseTransform(double du,
                                     double dv,
                                     double dw,
                                     Vector3 dxyz)
                              throws NoninvertibleTransformException
returns the world distance of a pixel distance by applying the inverse transform, but without using the translation part

Throws:
NoninvertibleTransformException

scale

public void scale(double sx,
                  double sy,
                  double sz)
Scales the model non-uniformly along the x, y and z-axes. The current transform matrix M is multiplied by:
      m00 m01 m02 m03       sx  0   0   0
      m10 m11 m12 m13       0   sy  0   0
      m20 m21 m22 m23       0   0   sz  0
      m30 m31 m32 m33       0   0   0   1
 


zoom

public void zoom(double sx,
                 double sy,
                 double sz)
Zooms the user non-uniformly along the x, y and z-axes. The current transform matrix M is pre-multiplied by:
      sx  0   0   0       m00 m01 m02 m03
      0   sy  0   0       m10 m11 m12 m13
      0   0   sz  0       m20 m21 m22 m23
      0   0   0   1       m30 m31 m32 m33
 


translateModel

public void translateModel(double tx,
                           double ty,
                           double tz)
Translates the current transform. The current transform matrix M is multiplied by:
      m00 m01 m02 m03         1   0   0   tx
      m10 m11 m12 m13         0   1   0   ty
      m20 m21 m22 m23         0   0   1   tz
      m30 m31 m32 m33         0   0   0   1
 


translate

public void translate(double tx,
                      double ty,
                      double tz)

rotate

public void rotate(double ux,
                   double uy,
                   double uz,
                   double theta)
Rotates over unit vector ux,uy,uz by angle theta (in radiants). The current Matrix M is multiplied by:
      m00 m01 m02 m03         x^2(1-c) + c    xy(1-c) - zs    xz(1-c) + ys    0
      m10 m11 m12 m13         yx(1-c) + zs    y^2(1-c) + c    yz(1-c) - xs    0
      m20 m21 m22 m23         xz(1-c) - ys    yz(1-c) + xs    z^2(1-c) + c    0
      m30 m31 m32 m33         0               0               0               1
 
where c = cos(theta), s = sin(theta) and ||(ux,uy,uz)|| = 1.


ortho

public void ortho(double left,
                  double right,
                  double bottom,
                  double top,
                  double near,
                  double far)
Creates a parallel projection. The current Matrix M is multiplied by:
      m00 m01 m02 m03         2/(right-left)  0               0               -(right+left)/(right-left)
      m10 m11 m12 m13         0               2/(top-bottom)  0               -(top+bottom)/(top-bottom)
      m20 m21 m22 m23         0               0               -2/(far-near)   -(far+near)/(far-near)
      m30 m31 m32 m33         0               0               0               1
 
where if denominators are 0 for scaling factors, the scale factor defaults to 1, and if denominators are 0 for translation factors, the translation factor defaults to 0.


frustum

public void frustum(double left,
                    double right,
                    double bottom,
                    double top,
                    double near,
                    double far)
Creates a perspective projection. The current Matrix M is multiplied by:
      m00 m01 m02 m03    2*near/(right-left) 0                   (right+left)/(right-left)  0
      m10 m11 m12 m13    0                   2*near/(top-bottom) (top+bottom)/(top-bottom)  0
      m20 m21 m22 m23    0                   0                   -(far+near)/(far-near)     -2*far*near/(far-near)
      m30 m31 m32 m33    0                   0                   -1                         0
 
where if denominators are 0 for scaling factors, the scale factor defaults to 1, and if denominators are 0 for translation factors, the translation factor defaults to 0.


multiply

public void multiply(Matrix4 matrix)
Multiply transform matrix by matrix.


setMatrix

public void setMatrix(Matrix4 matrix)
Set transform matrix to matrix.


getMatrix

public Matrix4 getMatrix()
Returns current transform.

Returns:
current transform matrix

equals

public boolean equals(Object object)
Returns:
true if current transform is equals to object

hashCode

public int hashCode()
Returns:
hashcode for current transform

toString

public String toString()
Returns:
string representation for this transform

validate

protected void validate()
Validates the current transform and extracts its parameters.

Taken from Graphics Gems II (page 466)


getTranslate

public Vector3 getTranslate(Vector3 v)

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.