Class Simple1DOFCamera
- java.lang.Object
-
- elki.visualization.parallel3d.util.Simple1DOFCamera
-
public class Simple1DOFCamera extends java.lang.ObjectClass for a simple camera. Restricted: always looks at 0,0,0 from a position defined by rotationX, distance and height.For rotationX = 0, the camera will be at y=distance, x=0, so that the default view will have the usual X/Y plane on the ground.
- Since:
- 0.6.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSimple1DOFCamera.CameraListenerCamera Listener class
-
Field Summary
Fields Modifier and Type Field Description private doublecosZCache the Z rotation cosineprivate doubledistanceDistanceprivate javax.media.opengl.glu.GLUgluGLU utilityprivate doubleheightHeight(package private) java.util.ArrayList<Simple1DOFCamera.CameraListener>listenersCamera listener list.private double[]modelviewGLU model view matrixprivate double[]projectionGLU projection matrixprivate doubleratioScreen ratioprivate doublerotationZRotation on X axis.private doublesinZCache the Z rotation sineprivate int[]viewpGLU viewport storage
-
Constructor Summary
Constructors Constructor Description Simple1DOFCamera(Simple1DOFCamera other)Copy constructor, for freezing a camera position.Simple1DOFCamera(javax.media.opengl.glu.GLU glu)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCameraListener(Simple1DOFCamera.CameraListener lis)Add a camera listener.voidapply(javax.media.opengl.GL2 gl)Apply the camera to a GL context.protected voidfireCameraChangedEvent()Fire the camera changed event.doublegetDistance()Get the distancedoublegetHeight()Get camera heightdoublegetRatio()Get screen ratio.doublegetRotationZ()Get the Z rotation in radians.voidproject(double x, double y, double z, double[] out)Project a coordinatevoidremoveCameraListener(Simple1DOFCamera.CameraListener lis)Remove a camera listener.voidsetDistance(double distance)Set camera distancevoidsetHeight(double height)Set camera heightvoidsetRatio(double ratio)Set screen ratio.voidsetRotationZ(double rotationZ)Set the z rotation angle in radians.doublesquaredDistanceFromCamera(double x, double y)Distance from cameradoublesquaredDistanceFromCamera(double x, double y, double z)Distance from cameradouble[]unproject(double x, double y, double z)Unproject a screen coordinate (at depth 0) to 3D model coordinates.voidunproject(double x, double y, double z, double[] out)Unproject a screen coordinate (at depth 0) to 3D model coordinates.
-
-
-
Field Detail
-
rotationZ
private double rotationZ
Rotation on X axis.
-
distance
private double distance
Distance
-
height
private double height
Height
-
ratio
private double ratio
Screen ratio
-
viewp
private int[] viewp
GLU viewport storage
-
modelview
private double[] modelview
GLU model view matrix
-
projection
private double[] projection
GLU projection matrix
-
glu
private javax.media.opengl.glu.GLU glu
GLU utility
-
cosZ
private double cosZ
Cache the Z rotation cosine
-
sinZ
private double sinZ
Cache the Z rotation sine
-
listeners
java.util.ArrayList<Simple1DOFCamera.CameraListener> listeners
Camera listener list.
-
-
Constructor Detail
-
Simple1DOFCamera
public Simple1DOFCamera(javax.media.opengl.glu.GLU glu)
Constructor.- Parameters:
glu- GLU utility class
-
Simple1DOFCamera
public Simple1DOFCamera(Simple1DOFCamera other)
Copy constructor, for freezing a camera position. Note: listeners will not be copied.- Parameters:
other- Existing camera
-
-
Method Detail
-
getDistance
public double getDistance()
Get the distance- Returns:
- Distance
-
setDistance
public void setDistance(double distance)
Set camera distance- Parameters:
distance- Distance
-
getHeight
public double getHeight()
Get camera height- Returns:
- Camera height
-
setHeight
public void setHeight(double height)
Set camera height- Parameters:
height- Camera height
-
getRatio
public double getRatio()
Get screen ratio.- Returns:
- Screen ratio
-
setRatio
public void setRatio(double ratio)
Set screen ratio.- Parameters:
ratio- Screen ratio
-
getRotationZ
public double getRotationZ()
Get the Z rotation in radians.- Returns:
- Z rotation angle (radians)
-
setRotationZ
public void setRotationZ(double rotationZ)
Set the z rotation angle in radians.- Parameters:
rotationZ- Z rotation angle.
-
apply
public void apply(javax.media.opengl.GL2 gl)
Apply the camera to a GL context.- Parameters:
gl- GL context.
-
unproject
public double[] unproject(double x, double y, double z)Unproject a screen coordinate (at depth 0) to 3D model coordinates.- Parameters:
x- Xy- Yz- Z- Returns:
- model coordinates
-
unproject
public void unproject(double x, double y, double z, double[] out)Unproject a screen coordinate (at depth 0) to 3D model coordinates.- Parameters:
x- Xy- Yz- Zout- output buffer
-
project
public void project(double x, double y, double z, double[] out)Project a coordinate- Parameters:
x- Xy- Yz- Zout- output buffer
-
squaredDistanceFromCamera
public double squaredDistanceFromCamera(double x, double y)Distance from camera- Parameters:
x- X positiony- Y position- Returns:
- Squared distance
-
squaredDistanceFromCamera
public double squaredDistanceFromCamera(double x, double y, double z)Distance from camera- Parameters:
x- X positiony- Y positionz- Z position- Returns:
- Squared distance
-
addCameraListener
public void addCameraListener(Simple1DOFCamera.CameraListener lis)
Add a camera listener.- Parameters:
lis- Listener
-
removeCameraListener
public void removeCameraListener(Simple1DOFCamera.CameraListener lis)
Remove a camera listener.- Parameters:
lis- Listener
-
fireCameraChangedEvent
protected void fireCameraChangedEvent()
Fire the camera changed event.
-
-