Package draw
Class Proj3D
java.lang.Object
draw.Proj3D
- All Implemented Interfaces:
Serializable
Class for projecting 3D points to a 2D plane.
- Since:
- 2004.06.02
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copy a projection object into this.void
Copy a projection object into another.double
cosine
(double[] x, double[] n) Compute the cosine of the angle between the viewing direction and the normal vector of the plane.double
cosine
(double x, double y, double z, double nx, double ny, double nz) Compute the cosine of the angle between the viewing direction and the normal vector of the plane.double
getX()
Get the x coordinate of a projection result.double
getY()
Get the y coordinate of a projection result.double
getZ()
Get the z coordinate of a projection result.boolean
isVisible
(double[] x, double[] n) Check whether (the upper side of) a plane is visible.boolean
isVisible
(double x, double y, double z, double nx, double ny, double nz) Check whether (the upper side of) a plane is visible.void
moveEye
(double[] d) Move the eye position (point to look from).void
moveEye
(double x, double y, double z) Move the eye position (point to look from).int
project
(double[] x) Project a given point into the plane.int
project
(double[] x, double[] p) Project a given point into the plane.int
project
(double x, double y, double z, double[] p) Project a given point into the plane.void
reset()
Reset all viewing parameters to their initial values.void
setEye
(double[] x) Set the eye position (point to look from).void
setEye
(double x, double y, double z) Set the eye position (point to look from).void
setFrustrum
(double fov, double dnear, double dfar) Set the viewing frustrum.void
setPitch
(double phi, int mode) Set the pitch angle.void
setRoll
(double phi, int mode) Set the roll angle.void
setScale
(double scale) Set the scaling factor.void
setView
(double h, double p, double r) Set the direction of view.void
setYaw
(double phi, int mode) Set the heading/yaw angle.
-
Field Details
-
VIEW
public static final int VIEWmode: change the view (coordinate system)- See Also:
-
EYE
public static final int EYEmode: change the eye position- See Also:
-
BOTH
public static final int BOTHmode: change view and eye position- See Also:
-
-
Constructor Details
-
Proj3D
public Proj3D()Create a 3D to 2D projection.- Since:
- 2004.06.02 (Christian Borgelt)
-
-
Method Details
-
setScale
public void setScale(double scale) Set the scaling factor.- Parameters:
scale
- the scaling factor to set- Since:
- 2004.06.02 (Christian Borgelt)
-
reset
public void reset()Reset all viewing parameters to their initial values.- Since:
- 2004.06.02 (Christian Borgelt)
-
copyTo
Copy a projection object into another.- Parameters:
p
- the projection object to copy to- Since:
- 2004.06.02 (Christian Borgelt)
-
copyFrom
Copy a projection object into this.- Parameters:
p
- the projection object to copy from- Since:
- 2007.02.07 (Christian Borgelt)
-
setEye
public void setEye(double x, double y, double z) Set the eye position (point to look from).- Parameters:
x
- the x-coordinate of the eyey
- the y-coordinate of the eyez
- the z-coordinate of the eye- Since:
- 2004.06.02 (Christian Borgelt)
-
setEye
public void setEye(double[] x) Set the eye position (point to look from).- Parameters:
x
- the position of the eye as a vector- Since:
- 2004.06.02 (Christian Borgelt)
-
moveEye
public void moveEye(double x, double y, double z) Move the eye position (point to look from).The movement coordinates are interpreted in the view coordinate system, not in the world coordinate system.
- Parameters:
x
- the amount to move in x directiony
- the amount to move in y directionz
- the amount to move in z direction- Since:
- 2004.06.02 (Christian Borgelt)
-
moveEye
public void moveEye(double[] d) Move the eye position (point to look from).The movement coordinates are interpreted in the view coordinate system, not in the world coordinate system.
- Parameters:
d
- the vector by which to move the eye- Since:
- 2004.06.02 (Christian Borgelt)
-
setView
public void setView(double h, double p, double r) Set the direction of view.- Parameters:
h
- the heading/yaw anglep
- the pitch angler
- the roll angle- Since:
- 2004.06.02 (Christian Borgelt)
-
setFrustrum
public void setFrustrum(double fov, double dnear, double dfar) Set the viewing frustrum.- Parameters:
fov
- the field of view (viewing angle)dnear
- the distance to the near planedfar
- the distance to the far plane- Since:
- 2004.06.02 (Christian Borgelt)
-
setYaw
public void setYaw(double phi, int mode) Set the heading/yaw angle.- Parameters:
phi
- the heading/yaw anglemode
- the mode for the adaptation- Since:
- 2004.06.02 (Christian Borgelt)
-
setPitch
public void setPitch(double phi, int mode) Set the pitch angle.- Parameters:
phi
- the pitch anglemode
- the mode for the adaptation- Since:
- 2004.06.02 (Christian Borgelt)
-
setRoll
public void setRoll(double phi, int mode) Set the roll angle.- Parameters:
phi
- the roll anglemode
- the mode for the adaptation- Since:
- 2004.06.02 (Christian Borgelt)
-
project
public int project(double x, double y, double z, double[] p) Project a given point into the plane.- Parameters:
x
- the x-coordinate of the pointy
- the y-coordinate of the pointz
- the z-coordinate of the pointp
- the vector into which to store the result- Returns:
- whether the point is inside the viewing frustrum, 0: inside viewing frustrum, -1: before near or beyond far plane, 1: between near and far plane, but outside field of view.
- Since:
- 2004.06.02 (Christian Borgelt)
-
project
public int project(double[] x, double[] p) Project a given point into the plane.- Parameters:
x
- the point to project as a vectorp
- the vector into which to store the result- Returns:
- whether the point is inside the viewing frustrum, 0: inside viewing frustrum, -1: before near or beyond far plane, 1: between near and far plane, but outside field of view.
- Since:
- 2004.06.02 (Christian Borgelt)
-
project
public int project(double[] x) Project a given point into the plane.The result of the projection is stored in an internal buffer.
- Parameters:
x
- the point to project as a vector- Returns:
- whether the point is inside the viewing frustrum, 0: inside viewing frustrum, -1: before near or beyond far plane, 1: between near and far plane, but outside field of view.
- Since:
- 2004.06.02 (Christian Borgelt)
-
getX
public double getX()Get the x coordinate of a projection result.- Returns:
- the x-coordinate of the projection result
- Since:
- 2004.06.02 (Christian Borgelt)
-
getY
public double getY()Get the y coordinate of a projection result.- Returns:
- the y-coordinate of the projection result
- Since:
- 2004.06.02 (Christian Borgelt)
-
getZ
public double getZ()Get the z coordinate of a projection result.- Returns:
- the z-coordinate of the projection result
- Since:
- 2004.06.02 (Christian Borgelt)
-
isVisible
public boolean isVisible(double x, double y, double z, double nx, double ny, double nz) Check whether (the upper side of) a plane is visible.- Parameters:
x
- the x-coordinate of a support vector of the planey
- the y-coordinate of a support vector of the planez
- the z-coordinate of a support vector of the planenx
- the x-coordinate of a normal vector of the planeny
- the y-coordinate of a normal vector of the planenz
- the z-coordinate of a normal vector of the plane- Returns:
- whether (the upper side of) a plane is visible
- Since:
- 2004.06.02 (Christian Borgelt)
-
isVisible
public boolean isVisible(double[] x, double[] n) Check whether (the upper side of) a plane is visible.- Parameters:
x
- a support vector of the planen
- a normal vector of the plane- Returns:
- whether (the upper side of) a plane is visible
- Since:
- 2004.06.02 (Christian Borgelt)
-
cosine
public double cosine(double x, double y, double z, double nx, double ny, double nz) Compute the cosine of the angle between the viewing direction and the normal vector of the plane.- Parameters:
x
- the x-coordinate of a support vector of the planey
- the y-coordinate of a support vector of the planez
- the z-coordinate of a support vector of the planenx
- the x-coordinate of a normal vector of the planeny
- the y-coordinate of a normal vector of the planenz
- the z-coordinate of a normal vector of the plane- Returns:
- the cosine of the angle between the viewing direction and the normal vector of the plane
- Since:
- 2004.06.02 (Christian Borgelt)
-
cosine
public double cosine(double[] x, double[] n) Compute the cosine of the angle between the viewing direction and the normal vector of the plane.- Parameters:
x
- a support vector of the planen
- a normal vector of the plane- Returns:
- the cosine of the angle between the viewing direction and the normal vector of the plane
- Since:
- 2004.06.02 (Christian Borgelt)
-