Package draw

Class Proj3D

java.lang.Object
draw.Proj3D
All Implemented Interfaces:
Serializable

public class Proj3D extends Object implements Serializable
Class for projecting 3D points to a 2D plane.
Since:
2004.06.02
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    mode: change view and eye position
    static final int
    mode: change the eye position
    static final int
    mode: change the view (coordinate system)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a 3D to 2D projection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    Get the x coordinate of a projection result.
    double
    Get the y coordinate of a projection result.
    double
    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 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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

      public void copyTo(Proj3D p)
      Copy a projection object into another.
      Parameters:
      p - the projection object to copy to
      Since:
      2004.06.02 (Christian Borgelt)
    • copyFrom

      public void copyFrom(Proj3D p)
      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 eye
      y - the y-coordinate of the eye
      z - 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 direction
      y - the amount to move in y direction
      z - 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 angle
      p - the pitch angle
      r - 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 plane
      dfar - 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 angle
      mode - 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 angle
      mode - 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 angle
      mode - 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 point
      y - the y-coordinate of the point
      z - the z-coordinate of the point
      p - 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 vector
      p - 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 plane
      y - the y-coordinate of a support vector of the plane
      z - the z-coordinate of a support vector of the plane
      nx - the x-coordinate of a normal vector of the plane
      ny - the y-coordinate of a normal vector of the plane
      nz - 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 plane
      n - 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 plane
      y - the y-coordinate of a support vector of the plane
      z - the z-coordinate of a support vector of the plane
      nx - the x-coordinate of a normal vector of the plane
      ny - the y-coordinate of a normal vector of the plane
      nz - 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 plane
      n - 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)