Class CameraPlane
- java.lang.Object
-
- org.openstreetmap.josm.gui.util.imagery.CameraPlane
-
public class CameraPlane extends java.lang.Object
The plane that the camera appears on and rotates around.- Since:
- 18246
-
-
Field Summary
Fields Modifier and Type Field Description static doubleHALF_PIprivate intheightThe height of the image(package private) static doublePANORAMA_FOVThe field of view for the panorama at 0 zoomprivate Vector3Drotationstatic doubleTWO_PIprivate Vector3D[][]vectorsprivate intwidthThe width of the imageprivate static byteYAW_DIRECTIONThis determines the yaw direction.
-
Constructor Summary
Constructors Modifier Constructor Description CameraPlane(int width, int height)Create a new CameraPlane with the default FOV (110 degrees).privateCameraPlane(int width, int height, double distance)Create a new CameraPlane
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcommonFastByteMapping(java.awt.image.BufferedImage sourceImage, java.awt.image.BufferedImage targetImage, java.awt.Rectangle visibleRect)intgetHeight()Get the height of the imagejava.awt.PointgetPoint(Vector3D vector)Get the point for a vectorVector3DgetRotation()Vector3DgetVector3D(double x, double y)Convert a point to a 3D vector.Vector3DgetVector3D(int x, int y)Convert a point to a 3D vector (vectors are cached)Vector3DgetVector3D(java.awt.Point p)Convert a point to a 3D vectorintgetWidth()Get the width of the imagevoidmapping(java.awt.image.BufferedImage sourceImage, java.awt.image.BufferedImage targetImage, java.awt.Rectangle visibleRect)Maps a panoramic view of sourceImage into targetImage based on current configuration of Camera Planejava.awt.geom.Point2D.DoublemapPoint(double x, double y)Map a real point to the displayed point.java.awt.geom.Point2D.DoublemapPoint(int x, int y)Map a real point to the displayed point.private Vector3Drotate(Vector3D vec)Rotate a vector using the current rotation(package private) voidsetRotation(double azimuthalAngle, double polarAngle)voidsetRotation(java.awt.Point p)Set camera plane rotation by current plane position.voidsetRotation(Vector3D vec)Set camera plane rotation by spherical vector.voidsetRotationFromDelta(java.awt.Point from, java.awt.Point to)Set the rotation from the difference of two points
-
-
-
Field Detail
-
PANORAMA_FOV
static final double PANORAMA_FOV
The field of view for the panorama at 0 zoom
-
YAW_DIRECTION
private static final byte YAW_DIRECTION
This determines the yaw direction. We may want to make it a config option, but maybe not- See Also:
- Constant Field Values
-
width
private final int width
The width of the image
-
height
private final int height
The height of the image
-
HALF_PI
public static final double HALF_PI
- See Also:
- Constant Field Values
-
TWO_PI
public static final double TWO_PI
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CameraPlane
public CameraPlane(int width, int height)
Create a new CameraPlane with the default FOV (110 degrees).- Parameters:
width- The width of the imageheight- The height of the image
-
CameraPlane
private CameraPlane(int width, int height, double distance)
Create a new CameraPlane- Parameters:
width- The width of the imageheight- The height of the imagedistance- The radial distance of the photosphere
-
-
Method Detail
-
getWidth
public int getWidth()
Get the width of the image- Returns:
- The width of the image
-
getHeight
public int getHeight()
Get the height of the image- Returns:
- The height of the image
-
getPoint
@Nullable public java.awt.Point getPoint(Vector3D vector)
Get the point for a vector- Parameters:
vector- the vector for which the corresponding point on the camera plane will be returned- Returns:
- the point on the camera plane to which the given vector is mapped, nullable
-
getVector3D
public Vector3D getVector3D(java.awt.Point p)
Convert a point to a 3D vector- Parameters:
p- The point to convert- Returns:
- The vector
-
getVector3D
public Vector3D getVector3D(int x, int y)
Convert a point to a 3D vector (vectors are cached)- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- The vector
-
getVector3D
public Vector3D getVector3D(double x, double y)
Convert a point to a 3D vector. Warning: This method does not cache.- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- The vector (the middle of the image is 0, 0)
-
setRotation
public void setRotation(java.awt.Point p)
Set camera plane rotation by current plane position.- Parameters:
p- Point within current plane.
-
setRotationFromDelta
public void setRotationFromDelta(java.awt.Point from, java.awt.Point to)
Set the rotation from the difference of two points- Parameters:
from- The originating pointto- The new point
-
setRotation
public void setRotation(Vector3D vec)
Set camera plane rotation by spherical vector.- Parameters:
vec- vector pointing new view position.
-
getRotation
public Vector3D getRotation()
-
setRotation
void setRotation(double azimuthalAngle, double polarAngle)
-
rotate
private Vector3D rotate(Vector3D vec)
Rotate a vector using the current rotation- Parameters:
vec- The vector to rotate- Returns:
- A rotated vector
-
mapping
public void mapping(java.awt.image.BufferedImage sourceImage, java.awt.image.BufferedImage targetImage, java.awt.Rectangle visibleRect)
Maps a panoramic view of sourceImage into targetImage based on current configuration of Camera Plane- Parameters:
sourceImage- The image to painttargetImage- The target imagevisibleRect- The part of target image which will be visible
-
commonFastByteMapping
private void commonFastByteMapping(java.awt.image.BufferedImage sourceImage, java.awt.image.BufferedImage targetImage, java.awt.Rectangle visibleRect)
-
mapPoint
public final java.awt.geom.Point2D.Double mapPoint(int x, int y)
Map a real point to the displayed point. This method uses cached vectors.- Parameters:
x- The original x coordinatey- The original y coordinate- Returns:
- The scaled (0-1) point in the image. Use
p.x * (image.getWidth() - 1)orp.y * image.getHeight() - 1.
-
mapPoint
public final java.awt.geom.Point2D.Double mapPoint(double x, double y)
Map a real point to the displayed point. This function does not use cached vectors.- Parameters:
x- The original x coordinatey- The original y coordinate- Returns:
- The scaled (0-1) point in the image. Use
p.x * (image.getWidth() - 1)orp.y * image.getHeight() - 1.
-
-