Class Point3d

java.lang.Object
com.ijurnove.cpu3d.Point3d
All Implemented Interfaces:
Rotatable, Scalable, Translatable

public class Point3d extends Object implements Translatable, Rotatable, Scalable
A Point3d is a specific point in 3D space. Point3d objects store two different positions as Matrixes, one for its position in 3D space, and one for its position on the screen.
  • Field Details

    • ORIGIN

      public static final Point3d ORIGIN
      A Point3d at (0, 0, 0)
  • Constructor Details

    • Point3d

      public Point3d(Matrix pos)
      Constructs a Point3d at the coordinates specified in a given Matrix. The Matrix should have 1 column and 3 or 4 rows. Row 1 is the X position, row 2 is the Y, and row 3 is the Z.
      Parameters:
      pos - the Matrix representing the constructed Point3d's coordinates
    • Point3d

      public Point3d(double x, double y, double z)
      Constructs a new Point3d at the given X, Y, and Z.
      Parameters:
      x - the X position of the constructed Point3d
      y - the Y position of the constructed Point3d
      z - the Z position of the constructed Point3d
  • Method Details

    • addAdjTri

      protected void addAdjTri(Triangle tri)
    • getAdjacentTris

      protected ArrayList<Triangle> getAdjacentTris()
    • getMatrix

      protected Matrix getMatrix()
    • getRenderCoords

      protected Matrix getRenderCoords()
    • renderArray

      protected double[][] renderArray()
    • xRend

      public double xRend()
      Returns the X position on the screen.
      Returns:
      the X position on the screen
    • yRend

      public double yRend()
      Returns the Y position on the screen.
      Returns:
      the Y position on the screen
    • depth

      public double depth()
      Returns the depth of this Point3d, or how far away it is from the camera.
      Returns:
      the depth
    • xReal

      public double xReal()
      Returns the X position in 3D space.
      Returns:
      the X position in 3D space
    • yReal

      public double yReal()
      Returns the Y position in 3D space.
      Returns:
      the Y position in 3D space
    • zReal

      public double zReal()
      Returns the Z position in 3D space.
      Returns:
      the Z position in 3D space
    • copy

      public Point3d copy()
      Returns a copy of this Point3d with a new reference.
      Returns:
      a copy of this Point3d
    • shiftValue

      protected void shiftValue(int axis, double distance)
    • setX

      public void setX(double newPos)
      Sets the X position.
      Parameters:
      newPos - the new X position
    • setY

      public void setY(double newPos)
      Sets the Y position.
      Parameters:
      newPos - the new Y position
    • setZ

      public void setZ(double newPos)
      Sets the Z position.
      Parameters:
      newPos - the new Z position
    • translate

      public void translate(double xShift, double yShift, double zShift)
      Description copied from interface: Translatable
      Shifts this object's X, Y, and Z position by the given values.
      Specified by:
      translate in interface Translatable
      Parameters:
      xShift - how far the object should be translated along the X axis
      yShift - how far the object should be translated along the Y axis
      zShift - how far the object should be translated along the Z axis
    • scale

      public void scale(double size, Point3d point)
      Description copied from interface: Scalable
      Scales this object by a given amount from a point.
      Specified by:
      scale in interface Scalable
      Parameters:
      size - the scale multiplier
      point - the point that this object should be scaled from
    • rotate

      public void rotate(int axis, double theta, Point3d point)
      Description copied from interface: Rotatable
      Rotates this object about a given point on a specified axis. 0 corresponds to the X axis, 1 corresponds to the Y axis, and 2 corresponds to the Z axis.
      Specified by:
      rotate in interface Rotatable
      Parameters:
      axis - the axis to rotate around
      theta - the radians to rotate by
      point - the center point to rotate around
    • rotate

      protected void rotate(int axis, double theta)
    • perspProjection

      protected void perspProjection(Camera cam)
    • perspProjectionForPointShadowMap

      protected void perspProjectionForPointShadowMap(Camera cam)
    • orthoProjection

      protected void orthoProjection(Camera cam)