Class Simple1DOFCamera
- java.lang.Object
-
- elki.visualization.parallel3d.util.Simple1DOFCamera
-
public class Simple1DOFCamera extends java.lang.Object
Class 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 interface
Simple1DOFCamera.CameraListener
Camera Listener class
-
Field Summary
Fields Modifier and Type Field Description private double
cosZ
Cache the Z rotation cosineprivate double
distance
Distanceprivate javax.media.opengl.glu.GLU
glu
GLU utilityprivate double
height
Height(package private) java.util.ArrayList<Simple1DOFCamera.CameraListener>
listeners
Camera listener list.private double[]
modelview
GLU model view matrixprivate double[]
projection
GLU projection matrixprivate double
ratio
Screen ratioprivate double
rotationZ
Rotation on X axis.private double
sinZ
Cache the Z rotation sineprivate int[]
viewp
GLU 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 void
addCameraListener(Simple1DOFCamera.CameraListener lis)
Add a camera listener.void
apply(javax.media.opengl.GL2 gl)
Apply the camera to a GL context.protected void
fireCameraChangedEvent()
Fire the camera changed event.double
getDistance()
Get the distancedouble
getHeight()
Get camera heightdouble
getRatio()
Get screen ratio.double
getRotationZ()
Get the Z rotation in radians.void
project(double x, double y, double z, double[] out)
Project a coordinatevoid
removeCameraListener(Simple1DOFCamera.CameraListener lis)
Remove a camera listener.void
setDistance(double distance)
Set camera distancevoid
setHeight(double height)
Set camera heightvoid
setRatio(double ratio)
Set screen ratio.void
setRotationZ(double rotationZ)
Set the z rotation angle in radians.double
squaredDistanceFromCamera(double x, double y)
Distance from cameradouble
squaredDistanceFromCamera(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.void
unproject(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.
-
-