mr3d.visualization
Class CentralProjectionCamera

java.lang.Object
  extended bymr3d.visualization.CentralProjectionCamera

public class CentralProjectionCamera
extends java.lang.Object

Projects 3D-points to a defined 2-dimensional view plane. The results are stored in the 3D-point objects x2d and y2d class variables.

Since:
MR3Dv1.0
Version:
12-2004
Author:
Manuel Ruelke

Field Summary
private static Vector3D cameraPosition
          Position of the camera in world coordinates.
(package private) static int chi
          Amount of degrees the camera is rotated relative to the world-coordinate-system.
(package private) static int displayCenterX
          X-value of the center of the display in display coordinates.
(package private) static int displayCenterY
          Y-value of the center of the display in display coordinates.
static int displayHeight
          Display height in pixel.
static int displayWidth
          Display width in pixel.
(package private) static int omega
          Amount of degrees the camera is rotated relative to the world-coordinate-system.
(package private) static int psi
          Amount of degrees the camera is rotated relative to the world-coordinate-system.
private static boolean recalculate
          Status variable.
private  Matrix rotMatrixWCStoCCS
          Rotation matrix for one part of the world to camera-coordinate conversion.
static int viewPlaneDistance
          Distance of the projection reference point (prp) to the view plane.
private static int viewVolumeFactorX
          Constant to calculate the view volume boundaries in the direction of x.
private static int viewVolumeFactorY
          Constant to calculate the view volume boundaries in the direction of y.
 
Constructor Summary
CentralProjectionCamera()
          Creates a new camera object.
 
Method Summary
private  void calculateViewVolumeFactors()
          Calculates the view volume factors.
 Vector3D getAngles()
          Returns the rotation of the camera-coordinate system relative to the world-coordinate system as 3d vector
 Vector3D getPosition()
          Returns the current position of the camera.
 boolean inViewVolume(Vector3D coords)
          Determines if the object is in the approximate view volume.
 void move(int x, int y, int z)
          Moves the center of the view plane relative to its current position in world coordinates.
 void moveTo(int x, int y, int z)
          Moves the center of the view plane to the specified point in world coordinates.
 void rotate(int addChi, int addPsi, int addOmega)
          Rotates the camera coordinate system relative to its current rotation.
 void setAngles(int chiX, int psiY, int omegaZ)
          Sets the rotation of the camera coordinate system relative to the world coordinate system.
 void setDisplayDimensions(int width, int height)
          Sets the display dimensions.
 void setViewPlaneDistance(int vpd)
          Sets the view plane distance to the specified value.
 void transformWCStoDCS()
          Performs a world-coordinate to display-coordinate transformation with all points in the PAT.
 Point3D transformWCStoDCS(Point3D projector)
          Performs a world-coordinate to display-coordinate transformation with the specified point.
 void transformWCStoDCS(TriangleBased3DObject obj)
          Performs a world-coordinate to display-coordinate transformation with all points in the specified 3d-object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cameraPosition

private static Vector3D cameraPosition
Position of the camera in world coordinates. This vector defines the coordinates of the center of the view plane.


chi

static int chi
Amount of degrees the camera is rotated relative to the world-coordinate-system. Chi defines the angle the camera-coordindate-system is rotated about the x-axis.


displayCenterX

static int displayCenterX
X-value of the center of the display in display coordinates.


displayCenterY

static int displayCenterY
Y-value of the center of the display in display coordinates.


displayHeight

public static int displayHeight
Display height in pixel.


displayWidth

public static int displayWidth
Display width in pixel.


omega

static int omega
Amount of degrees the camera is rotated relative to the world-coordinate-system. Omega defines the angle the camera-coordindate-system is rotated about the z-axis.


psi

static int psi
Amount of degrees the camera is rotated relative to the world-coordinate-system. Psi defines the angle the camera-coordindate-system is rotated about the y-axis.


recalculate

private static boolean recalculate
Status variable. "True" if the rotation matrix for the wcs to dcs conversion needs to be racalculated. That happens when the rotation of the camera changes.


rotMatrixWCStoCCS

private Matrix rotMatrixWCStoCCS
Rotation matrix for one part of the world to camera-coordinate conversion.


viewPlaneDistance

public static int viewPlaneDistance
Distance of the projection reference point (prp) to the view plane. The prp in defined to be at the tip of the vector (0,0,viewPlaneDistance) originating from the center of the view plane and enclosing an angle of 90 degrees with the view plane. Initial value is 300.


viewVolumeFactorX

private static int viewVolumeFactorX
Constant to calculate the view volume boundaries in the direction of x.


viewVolumeFactorY

private static int viewVolumeFactorY
Constant to calculate the view volume boundaries in the direction of y.

Constructor Detail

CentralProjectionCamera

public CentralProjectionCamera()
Creates a new camera object.

Method Detail

calculateViewVolumeFactors

private void calculateViewVolumeFactors()
Calculates the view volume factors. These factores are used to approximately reduce the objects that are in the view volume. This calculatiion uses a viewvolume defined by a twice as heigh and twice as wide display. If this still isn't enough (if you are using really large objects) aou might want to reprogramm this method.


getAngles

public Vector3D getAngles()
Returns the rotation of the camera-coordinate system relative to the world-coordinate system as 3d vector

Returns:
3d vector containing (chi, psi omega)

getPosition

public Vector3D getPosition()
Returns the current position of the camera.

Returns:
camera position vector

inViewVolume

public boolean inViewVolume(Vector3D coords)
Determines if the object is in the approximate view volume.

Parameters:
coords - coordinate vector to be tested
Returns:
"true" if coordinate vector is within view volume boundaries

move

public void move(int x,
                 int y,
                 int z)
Moves the center of the view plane relative to its current position in world coordinates.

Parameters:
x - x the value to be added to the camera position
y - y the value to be added to the camera position
z - z the value to be added to the camera position

moveTo

public void moveTo(int x,
                   int y,
                   int z)
Moves the center of the view plane to the specified point in world coordinates.

Parameters:
x - x value of the new camera position
y - y value of the new camera position
z - z value of the new camera position

rotate

public void rotate(int addChi,
                   int addPsi,
                   int addOmega)
Rotates the camera coordinate system relative to its current rotation.

Parameters:
addChi - the value to be added to the chi-angle
addPsi - the value to be added to the psi-angle
addOmega - the value to be added to the omega-angle

setAngles

public void setAngles(int chiX,
                      int psiY,
                      int omegaZ)
Sets the rotation of the camera coordinate system relative to the world coordinate system.

Parameters:
chiX - new rotation abgle about x-axis
psiY - new rotation abgle about y-axis
omegaZ - new rotation abgle about z-axis

setDisplayDimensions

public void setDisplayDimensions(int width,
                                 int height)
Sets the display dimensions.

Parameters:
width - width of the display in pixel
height - height of the display in pixel

setViewPlaneDistance

public void setViewPlaneDistance(int vpd)
Sets the view plane distance to the specified value. The view plane distance should be a value grater than zero.

Parameters:
vpd - new view plane distance

transformWCStoDCS

public void transformWCStoDCS()
Performs a world-coordinate to display-coordinate transformation with all points in the PAT. The result of the transformation is stored in the x2d and y2d variables in the 3d-point objects.


transformWCStoDCS

public Point3D transformWCStoDCS(Point3D projector)
Performs a world-coordinate to display-coordinate transformation with the specified point. The result of the transformation is stored in the x2d and y2d variables in the 3d-point.

Parameters:
projector - point to be projected on the view plane

transformWCStoDCS

public void transformWCStoDCS(TriangleBased3DObject obj)
Performs a world-coordinate to display-coordinate transformation with all points in the specified 3d-object. The result of the transformation is stored in the c2d and y2d variables on the 3D-points.

Parameters:
obj - 3d-object to be projected on the view plane