

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object vmm.core.Transform vmm.core3D.Transform3D
public class Transform3D
A transform that encodes a 3D view of an exhibit and the projection of that view onto a 2D view plane. This class inherits the windowtoviewport transformation from its superclass, and adds a 3D viewing transformation.
The projection is defined by three unit vectors: ViewDirection, ImagePlaneYDirection, and ImagePlaneXDirection. The ViewDirection is determined by the viewpoint that is specified for the view; ViewDirection is a unit vector that points in the direction from the viewpoint towards (0,0,0). The ViewDirection determines the viewing plane, which is a plane through (0,0,0) normal to the view direction. The ImagePlaneYDirection vector is obtained by projecting a "view up" vector onto the viewing plane, and then normalizing the projection. Initially, the view up vector is (0,0,1) or, if (0,0,1) almost normal to the view plane, (0,1,0). When the viewpoint is modified, the new ImagePlaneYDirection is obtained by using the previous ImagePlaneYDirection as the view up vector, if possible. After the ViewDirection and ImagePlaneYDirection are determined, the ImagePlaneXDirection is simply the cross product of these two vectors.
The transform also has an associated "focalLength" which is set to the distance of the viewpoint from the origin, and a clipDistance, which is set to 25% of the focal length.
A Transform3D fires a ChangeEvent when any part of the data that determines a 3D view is changed, such as the viewpoint.
(Note that in the default view, the yzplane projects onto the screen, and the xaxis is perpendicular to the screen. Nevertheless, the screen is thought of as being the xyplane.) TODO: Possibly add support for using a point other than (0,0,0) as the view reference point; check how clip distance and focal length should be changed when viewpoint is changed.
Field Summary 

Fields inherited from class vmm.core.Transform 

g, untransformedGraphics 
Constructor Summary  

Transform3D()
Creates a Transform3D object with default viewpoint (20,0,0) and a default window with x and y ranges from 5 to 5. 

Transform3D(Transform tr)
Construct a Transform3D with the same transform data as a specified transform. 

Transform3D(Vector3D viewPoint)
Creates a Transform3D object with a specified viewpoint and a default window with x and y ranges from 5 to 5. 

Transform3D(Vector3D viewPoint,
double nominalGraphicScale)
Creates a Transform3D with a specifed viewpoint and with an xywindow determined by a given "graphic scale" 

Transform3D(Vector3D viewPoint,
double xmin,
double xmax,
double ymin,
double ymax)
Construct a Transform3D with specified viewpoint and xywindow. 
Method Summary  

void 
applyTransvection(Vector3D e1,
Vector3D e2)
Rotates vector e1 onto vector e2, resulting in a change of view. 
java.lang.Object 
clone()
Creates a copy of this Transform3D. 
boolean 
equals(java.lang.Object obj)
Tests whether obj is a Transform3D with the same transform data as this transform, that is, both Transform.hasSameViewTransform(Transform) and
hasSameProjection(Transform3D) are true. 
double 
getClipDistance()
Returns the clip distance. 
double 
getFocalLength()
Gets the focal length, which is just the distance from the viewpoint to the origin. 
Vector3D 
getImagePlaneXDirection()
Gets the current ImagePlaneXDirection, one of the three unit vectors that determine the projection. 
Vector3D 
getImagePlaneYDirection()
Gets the current ImagePlaneYDirection, one of the three unit vectors that determine the projection. 
double 
getObjectDisplacementNormalToScreen()
Get the amount by which object coordinates are displaed normal to the screen. 
boolean 
getOrthographicProjection()
Returns true if the projection is an orthographic projection, or false if it is a perspective projection. 
Vector3D 
getViewDirection()
Gets the current ViewDirection, one of the three unit vectors that determine the projection. 
Vector3D 
getViewPoint()
Returns the current viewpoint of the transformation. 
boolean 
hasSameProjection(Transform3D tr)
Tests whether tr has the same projection from 3D to the view plane as this transform (but not necessarily the same window and viewport). 
java.awt.geom.Point2D 
objectToDrawingCoords(Vector3D objectPoint)
Transform a point given in world coordinates to a 2D point that can be used for drawing on the view plane. 
void 
objectToDrawingCoords(Vector3D objectPoint,
java.awt.geom.Point2D drawingCoords)
Transform a point given in world coordinates to a 2D point that can be used for drawing on the view plane. 
Vector3D 
objectToViewCoords(Vector3D objectPoint)
Transform a point in world coordinates to viewing coodinates. 
void 
objectToViewCoords(Vector3D objectPoint,
Vector3D viewCoords)
Transform a point from object coordinates to viewing coordinates. 
double 
objectToViewZ(Vector3D objectPoint)
Compute just the zcoordinate of a given point in view coordinates. 
java.awt.geom.Point2D 
objectToXYWindowCoords(Vector3D objectPoint)
Project a worldcoordinate point onto the view plane. 
void 
objectToXYWindowCoords(Vector3D objectPoint,
java.awt.geom.Point2D p)
Project a worldcoordinate point onto the view plane. 
void 
setClipDistance(double clipDistance)
Set the clip distance. 
void 
setImagePlaneYDirection(Vector3D viewUp)
Sets both the imagePlaneYDirection and imagePlaneXDirection so that these two vectors and the viewDirection (which points to the viewpoint) form an orthonomal system. 
void 
setObjectDisplacementNormalToScreen(double objectDisplacementNormalToScreen)
Set the amount by which object coordinates are displaed normal to the screen. 
void 
setOrthographicProjection(boolean orthographicProjection)
Sets whether the projection from 3D onto the viewplane should be a perspective projection or an orthographic projection. 
void 
setViewPoint(Vector3D viewPoint)
Sets the viewpoint of the transformation. 
Methods inherited from class java.lang.Object 

finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Constructor Detail 

public Transform3D()
public Transform3D(Vector3D viewPoint)
viewPoint
 the viewpoint of the transformation. If null, the default, (20,0,0), is used.public Transform3D(Vector3D viewPoint, double nominalGraphicScale)
viewPoint
 the viewpoint of the transformation. If null, the default, (20,0,0), is used.nominalGraphicScale
 number of pixels per unit along the x and yaxes, assuming that the size of
the window is "normal". The normal size is given by a private constant NORMAL_SIZE
, which
is set to 600 at the time this comment was written.public Transform3D(Vector3D viewPoint, double xmin, double xmax, double ymin, double ymax)
Transform.setUpDrawInfo(Graphics2D, int, int, int, int, boolean, boolean)
is called.
Note that when that method is called with its preserveAspect option set to true, the
requested xmin, xmax, ymin, and ymax values might be adjusted to make the aspect ratio of
the xywindow match the aspect ratio of the viewport.
viewPoint
 The viewpoint of the transformation; if null, the default, (20,0,0), is used.xmin
 the requested mimimum xvalue for the transformationxmax
 the requested maximum xvalue for the transformationymin
 the requested mimimum yvalue for the transformationymax
 the requested maximum yvalue for the transformationpublic Transform3D(Transform tr)
tr
 the nonnull transform whose data is to be copied.Method Detail 

public boolean getOrthographicProjection()
setOrthographicProjection(boolean)
public void setOrthographicProjection(boolean orthographicProjection)
orthographicProjection
 "true" to use an orthographic projection; "false" to use a perspective projection.public void setViewPoint(Vector3D viewPoint)
setImagePlaneYDirection(Vector3D)
with the current ImagePlaneYDirection
as parameter. In addition, the focal length is set to the distance of the viewpoint
from (0,0,0), the clip distance is set to 0.25 times the focal length, and the
ViewDirection is set to be a unit vector that points from the viewpoint towards (0,0,0).
viewPoint
 the new viewpoint; if null, the default, (20,0,0), is used.
The viewpoint cannot be (0,0,0), or the result will be an undefined transformation.
Note that a copy of the viewPoint parameter is made (if it is nonnull).
(Note: Also turns off left/right eye selection, if in use.)public Vector3D getViewPoint()
public double getClipDistance()
setClipDistance(double)
public void setClipDistance(double clipDistance)
setViewPoint(Vector3D)
. That method sets the clipDistance to 0.25 times the distance
from the viewpoint to the origin.
public double getFocalLength()
public double getObjectDisplacementNormalToScreen()
setObjectDisplacementNormalToScreen(double)
public void setObjectDisplacementNormalToScreen(double objectDisplacementNormalToScreen)
public Vector3D getImagePlaneXDirection()
setImagePlaneYDirection(Vector3D)
public Vector3D getImagePlaneYDirection()
setImagePlaneYDirection(Vector3D)
public Vector3D getViewDirection()
setViewPoint(Vector3D)
,
setImagePlaneYDirection(Vector3D)
public void setImagePlaneYDirection(Vector3D viewUp)
viewUp
 the new imagePlaneYDirection, which will point upwards on the screen.public void applyTransvection(Vector3D e1, Vector3D e2)
public boolean equals(java.lang.Object obj)
Transform.hasSameViewTransform(Transform)
and
hasSameProjection(Transform3D)
are true.
equals
in class Transform
public boolean hasSameProjection(Transform3D tr)
public java.lang.Object clone()
clone
in class Transform
public void objectToViewCoords(Vector3D objectPoint, Vector3D viewCoords)
objectPoint
 The nonnull point whose coordinates are to be transformed. This vector is not modified.viewCoords
 The nonnull vector that will contain the result after this method is called. The previous
components of this vector are replaced with the transformed version of objectPoint.public Vector3D objectToViewCoords(Vector3D objectPoint)
objectToViewCoords(Vector3D, Vector3D)
with a newly created vector as its
second argument, and then returning that vector.
objectPoint
 The nonnull point that is to be transformed
public void objectToXYWindowCoords(Vector3D objectPoint, java.awt.geom.Point2D p)
objectToViewCoords(Vector3D, Vector3D)
.
objectPoint
 a nonnull vector whose corrdinates are to be transformedp
 a nonnull point whose coordinates will be set to the projected (x,y) point.public java.awt.geom.Point2D objectToXYWindowCoords(Vector3D objectPoint)
objectToDrawingCoords(Vector3D, Point2D)
with a newly created Poin2D as its second
parameter, and then returning that point.
public void objectToDrawingCoords(Vector3D objectPoint, java.awt.geom.Point2D drawingCoords)
Transform.appliedTransform2D
property is true, the result is
the same as the result of objectToXYWindowCoords(Vector3D, Point2D)
, since regular
xy window coordinates can be used for drawing directly. If the Transform.appliedTransform2D
property is
false, then the xycoordinates are further transformed to the viewport (pixel) coordintates that
are needed for drawing.
objectPoint
 The point whose coordinates are to be projeted and transformed.drawingCoords
 A preallocated nonnull point to contain the result.public java.awt.geom.Point2D objectToDrawingCoords(Vector3D objectPoint)
objectToDrawingCoords(Vector3D, Point2D)
to
a newly allocated Point2D, and then returning that point.
public double objectToViewZ(Vector3D objectPoint)
objectToViewCoords(Vector3D)
objectPoint
 the untransformed point in object coordinates


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 