Class Camera
java.lang.Object
org.opensourcephysics.display3d.simple3d.Camera
- All Implemented Interfaces:
Camera
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.opensourcephysics.display3d.core.Camera
Camera.Loader -
Field Summary
Fields inherited from interface org.opensourcephysics.display3d.core.Camera
MODE_NO_PERSPECTIVE, MODE_PERSPECTIVE, MODE_PERSPECTIVE_OFF, MODE_PERSPECTIVE_ON, MODE_PLANAR_XY, MODE_PLANAR_XZ, MODE_PLANAR_YZ -
Method Summary
Modifier and TypeMethodDescriptionvoidCopies its configuration from another camerafinal doubleGet the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point.final doubleGet the horizontal angle of the camera position in spherical coordinates with respect to the focus point.final doubleReturns the distance from the camera to the projecting screen.final doubleReturns the focus X coordinatefinal doubleReturns the focus Y coordinatefinal doubleReturns the focus Z coordinatestatic XML.ObjectLoaderfinal intGets the projecting mode of the camera.final doubleReturns the angle that the camera is rotated along the line of sight.final TransformationReturns the transfomation used to project (x,y,z) points in space to points of the form (a,b,distance).final doublegetX()Returns the camera X coordinatefinal doublegetY()Returns the camera Y coordinatefinal doublegetZ()Returns the camera Z coordinatevoidreset()Resets the camera to the default.voidsetAltitude(double angle) Set the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point.voidsetAzimuth(double angle) Set the azimuthal (horizontal) angle of the camera position in spherical coordinates with respect to the focus point.voidsetAzimuthAndAltitude(double azimuth, double altitude) Set the angles of the camera position in spherical coordinates with respect to the focus point.voidsetDistanceToScreen(double distance) Sets the distance from the camera to the projecting screen.voidsetFocusXYZ(double[] point) Sets the focus of the camera.voidsetFocusXYZ(double x, double y, double z) Sets the focus point of the camera.voidsetProjectionMode(int mode) Sets one of the projecting modes.voidsetRotation(double angle) Sets the angle that the camera is rotated along the line of sight.voidsetXYZ(double[] point) Sets the position of the camera.voidsetXYZ(double x, double y, double z) Sets the position of the camera.
-
Method Details
-
setProjectionMode
public void setProjectionMode(int mode) Description copied from interface:CameraSets one of the projecting modes. Possible values are:- MODE_PERSPECTIVE or MODE_PERSPECTIVE_ON: 3D mode in which objects far away look smaller.
- MODE_NO_PERSPECTIVE or MODE_PERSPECTIVE_OFF: 3D mode in which distance doesn't affect the size of the objects
- MODE_PLANAR_XY: 2D mode in which only the X and Y coordinates are displayed.
- MODE_PLANAR_XZ: 2D mode in which only the X and Z coordinates are displayed.
- MODE_PLANAR_YZ: 2D mode in which only the Y and Z coordinates are displayed.
Changing the mode does not reset the camera.
- Specified by:
setProjectionModein interfaceCamera- Parameters:
mode- int
-
getProjectionMode
public final int getProjectionMode()Description copied from interface:CameraGets the projecting mode of the camera.- Specified by:
getProjectionModein interfaceCamera- Returns:
- int #see #setProjectionMode(int)
-
reset
public void reset()Description copied from interface:CameraResets the camera to the default. The camera is placed along the X direction, at a reasonable distance from the center of the panel, which becomes the focus, and is not rotated. The screen is also placed at a reasonable distance so that to view the whole scene. -
setXYZ
public void setXYZ(double x, double y, double z) Description copied from interface:CameraSets the position of the camera. -
setXYZ
public void setXYZ(double[] point) Description copied from interface:CameraSets the position of the camera. -
getX
public final double getX()Description copied from interface:CameraReturns the camera X coordinate -
getY
public final double getY()Description copied from interface:CameraReturns the camera Y coordinate -
getZ
public final double getZ()Description copied from interface:CameraReturns the camera Z coordinate -
setFocusXYZ
public void setFocusXYZ(double x, double y, double z) Description copied from interface:CameraSets the focus point of the camera. That it, the point in space at which the camera is pointing.- Specified by:
setFocusXYZin interfaceCamera- Parameters:
x- doubley- doublez- double
-
setFocusXYZ
public void setFocusXYZ(double[] point) Description copied from interface:CameraSets the focus of the camera.- Specified by:
setFocusXYZin interfaceCamera- Parameters:
point- double[]
-
getFocusX
public final double getFocusX()Description copied from interface:CameraReturns the focus X coordinate -
getFocusY
public final double getFocusY()Description copied from interface:CameraReturns the focus Y coordinate -
getFocusZ
public final double getFocusZ()Description copied from interface:CameraReturns the focus Z coordinate -
setRotation
public void setRotation(double angle) Description copied from interface:CameraSets the angle that the camera is rotated along the line of sight. Default is 0.- Specified by:
setRotationin interfaceCamera- Parameters:
angle- double The angle in radians
-
getRotation
public final double getRotation()Description copied from interface:CameraReturns the angle that the camera is rotated along the line of sight.- Specified by:
getRotationin interfaceCamera- Returns:
- double
-
setDistanceToScreen
public void setDistanceToScreen(double distance) Description copied from interface:CameraSets the distance from the camera to the projecting screen.- Specified by:
setDistanceToScreenin interfaceCamera- Parameters:
distance- double
-
getDistanceToScreen
public final double getDistanceToScreen()Description copied from interface:CameraReturns the distance from the camera to the projecting screen.- Specified by:
getDistanceToScreenin interfaceCamera- Returns:
- double
-
setAzimuth
public void setAzimuth(double angle) Description copied from interface:CameraSet the azimuthal (horizontal) angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 places the camera in the XZ plane.- Specified by:
setAzimuthin interfaceCamera- Parameters:
angle- the desired angle in radians
-
getAzimuth
public final double getAzimuth()Description copied from interface:CameraGet the horizontal angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 means the camera is in the XZ plane.- Specified by:
getAzimuthin interfaceCamera- Returns:
- double
-
setAltitude
public void setAltitude(double angle) Description copied from interface:CameraSet the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 places the camera is in the XY plane.- Specified by:
setAltitudein interfaceCamera- Parameters:
angle- the desired angle in radians in the range [-Math.PI/2,Math.PI/2]
-
getAltitude
public final double getAltitude()Description copied from interface:CameraGet the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 means the camera is in the XY plane.- Specified by:
getAltitudein interfaceCamera- Returns:
- double
-
setAzimuthAndAltitude
public void setAzimuthAndAltitude(double azimuth, double altitude) Description copied from interface:CameraSet the angles of the camera position in spherical coordinates with respect to the focus point.- Specified by:
setAzimuthAndAltitudein interfaceCamera- Parameters:
azimuth- the desired azimuthal angle in radiansaltitude- the desired altitude angle in radians in the range [-Math.PI/2,Math.PI/2]
-
getTransformation
Description copied from interface:CameraReturns the transfomation used to project (x,y,z) points in space to points of the form (a,b,distance). (a,b) are the coordinates of the projected point in the screen coordinate system. distance is a measure of how far the point is from the camera. Typically, points in the plane parallel to the screen at the focus point are at distance=1.- Specified by:
getTransformationin interfaceCamera- Returns:
- double
-
copyFrom
Description copied from interface:CameraCopies its configuration from another camera -
getLoader
-