Package draw

Class Point3D

java.lang.Object
draw.Point3D
All Implemented Interfaces:
Serializable, Comparable<Point3D>

public class Point3D extends Object implements Comparable<Point3D>, Serializable
Class for colored 3D points and their projection.
Since:
2004.06.02
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    the color of the point
    protected double[]
    the projection of the point in 2D space
    protected double
    the x-coordinate of the point in 3D space
    protected double
    the y-coordinate of the point in 3D space
    protected double
    the z-coordinate of the point in 3D space
  • Constructor Summary

    Constructors
    Constructor
    Description
    Point3D(double x, double y, double z)
    Create an uncolored 3D point (color 0).
    Point3D(double x, double y, double z, int c)
    Create a colored 3D point.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compare the depths of the projections of two points.
    int
    Project a colored 3D point.
    void
    scale(double s)
    Scale a colored 3D point.

    Methods inherited from class java.lang.Object

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

    • x

      protected double x
      the x-coordinate of the point in 3D space
    • y

      protected double y
      the y-coordinate of the point in 3D space
    • z

      protected double z
      the z-coordinate of the point in 3D space
    • c

      protected int c
      the color of the point
    • p

      protected double[] p
      the projection of the point in 2D space
  • Constructor Details

    • Point3D

      public Point3D(double x, double y, double z, int c)
      Create a colored 3D point.
      Parameters:
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      z - the z-coordinate of the point
      c - the color of the point
      Since:
      2004.06.02 (Christian Borgelt)
    • Point3D

      public Point3D(double x, double y, double z)
      Create an uncolored 3D point (color 0).
      Parameters:
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      z - the z-coordinate of the point
      Since:
      2004.06.02 (Christian Borgelt)
  • Method Details

    • scale

      public void scale(double s)
      Scale a colored 3D point.
      Parameters:
      s - the scaling factor for multiplying the coordinates
      Since:
      2014.01.27 (Christian Borgelt)
    • project

      public int project(Proj3D proj)
      Project a colored 3D point.
      Parameters:
      proj - the 3D to 2D projection to use
      Returns:
      whether the point is inside the viewing frustrum
      Since:
      2004.06.02 (Christian Borgelt)
    • compareTo

      public int compareTo(Point3D obj)
      Compare the depths of the projections of two points.
      Specified by:
      compareTo in interface Comparable<Point3D>
      Parameters:
      obj - the point to compare to
      Returns:
      -1, if this point is nearer to the eye,
      +1, if this point is farther from the eye,
      0, if both points have the same distance
      Since:
      2004.06.02 (Christian Borgelt)