Class Vertex


  • public final class Vertex
    extends Object
    A Vertex object has four doubles which represent the homogeneous coordinates of a point in 3-dimensional space. The fourth, homogeneous, coordinate will usually be 1, but in some stages of the graphics rendering pipeline it can be some other (non-zero) number.

    When a Vertex object is created in a client program, before the Vertex object moves down the graphics rendering pipeline, the coordinates in the Vertex will be in some model's local coordinate system.

    As a Vertex object moves down the graphics rendering pipeline, the coordinates in the Vertex will be transformed from one coordinate system to another.

    A Vertex object is immutable, so after it gets created it cannot be modified (mutated). So a Vertex object does not really "move" down the graphics pipeline. When a Vertex object needs to be transformed, we replace it, with a new Vertex object, instead of mutating it.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      double w  
      double x  
      double y  
      double z  
    • Constructor Summary

      Constructors 
      Constructor Description
      Vertex​(double x, double y, double z)
      Construct a new Vertex (with homogeneous coordinates) using the given x, y, and z coordinates.
      Vertex​(double x, double y, double z, double w)
      Construct a new Vertex with the given homogeneous coordinates.
    • Field Detail

      • x

        public final double x
      • y

        public final double y
      • z

        public final double z
      • w

        public final double w
    • Constructor Detail

      • Vertex

        public Vertex​(double x,
                      double y,
                      double z)
        Construct a new Vertex (with homogeneous coordinates) using the given x, y, and z coordinates.
        Parameters:
        x - x-coordinate of the new Vertex
        y - y-coordinate of the new Vertex
        z - z-coordinate of the new Vertex
      • Vertex

        public Vertex​(double x,
                      double y,
                      double z,
                      double w)
        Construct a new Vertex with the given homogeneous coordinates.
        Parameters:
        x - x-coordinate of the new Vertex
        y - y-coordinate of the new Vertex
        z - z-coordinate of the new Vertex
        w - w-coordinate of the new Vertex
    • Method Detail

      • toString

        public String toString​(int precision)
        For debugging.

        Allow the precision of the formatted output to be specified.

        Parameters:
        precision - precision value for the format string
        Returns:
        String representation of this Vertex object
      • toString

        public String toString​(int precision,
                               int iWidth)
        For debugging.

        Allow the precision and width of the formatted output to be specified. By width, we mean the width of the integer part of each number.

        Parameters:
        precision - precision value for the format string
        iWidth - width of the integer part of the format string
        Returns:
        String representation of this Vertex object