Package geomerative

Class RMatrix


  • public class RMatrix
    extends java.lang.Object
    RMatrix is a very simple interface for creating, holding 3x3 matrices with the most common 2D affine transformations such as translation, rotation, scaling and shearing. We only have access to the first to rows of the matrix the last row is considered a constant 0, 0, 1 in order to have better performance.
    • Constructor Summary

      Constructors 
      Constructor Description
      RMatrix()
      Create a new identity matrix.
      RMatrix​(float m00, float m01, float m02, float m10, float m11, float m12)
      Create a new matrix given the coefficients.
      RMatrix​(RMatrix src)
      Copy a matrix.
      RMatrix​(java.lang.String transformationString)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void apply​(float n00, float n01, float n02, float n10, float n11, float n12)
      Multiply the matrix with another matrix.
      void apply​(RMatrix rhs)
      Multiply the matrix with another matrix.
      void rotate​(float angle)  
      void rotate​(float angle, float vx, float vy)
      Apply a rotation to the matrix, given an angle and optionally a rotation center.
      void rotate​(float angle, RPoint v)
      Apply a rotation to the matrix, given an angle and optionally a rotation center.
      void scale​(float s)  
      void scale​(float sx, float sy)  
      void scale​(float s, float x, float y)
      Apply a scale to the matrix, given scaling factors and optionally a scaling center.
      void scale​(float sx, float sy, float x, float y)
      Apply a scale to the matrix, given scaling factors and optionally a scaling center.
      void scale​(float sx, float sy, RPoint p)
      Apply a scale to the matrix, given scaling factors and optionally a scaling center.
      void scale​(float s, RPoint p)
      Apply a scale to the matrix, given scaling factors and optionally a scaling center.
      void shear​(float shx, float shy)
      Use this to apply a shearing to the matrix.
      void skewX​(float angle)
      Use this to apply a skewing to the matrix.
      void skewY​(float angle)  
      void translate​(float tx)  
      void translate​(float tx, float ty)
      Apply a translation to the matrix, given the coordinates.
      void translate​(RPoint t)
      Apply a translation to the matrix, given a point.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RMatrix

        public RMatrix​(float m00,
                       float m01,
                       float m02,
                       float m10,
                       float m11,
                       float m12)
        Create a new matrix given the coefficients.
        Parameters:
        m00 - coefficient 00 of the matrix
        m01 - coefficient 01 of the matrix
        m02 - coefficient 02 of the matrix
        m10 - coefficient 10 of the matrix
        m11 - coefficient 11 of the matrix
        m12 - coefficient 12 of the matrix
      • RMatrix

        public RMatrix()
        Create a new identity matrix.
      • RMatrix

        public RMatrix​(RMatrix src)
        Copy a matrix.
        Parameters:
        src - source matrix from where to copy the matrix
      • RMatrix

        public RMatrix​(java.lang.String transformationString)
    • Method Detail

      • apply

        public void apply​(float n00,
                          float n01,
                          float n02,
                          float n10,
                          float n11,
                          float n12)
        Multiply the matrix with another matrix. This is mostly use to chain transformations.
        Parameters:
        n00 - coefficient 00 of the matrix to be applied
        n01 - coefficient 01 of the matrix to be applied
        n02 - coefficient 02 of the matrix to be applied
        n10 - coefficient 10 of the matrix to be applied
        n11 - coefficient 11 of the matrix to be applied
        n12 - coefficient 12 of the matrix to be applied
      • apply

        public void apply​(RMatrix rhs)
        Multiply the matrix with another matrix. This is mostly use to chain transformations.
        Parameters:
        rhs - right hand side matrix
      • translate

        public void translate​(float tx,
                              float ty)
        Apply a translation to the matrix, given the coordinates.
        Parameters:
        tx - x coordinate translation
        ty - y coordinate translation
      • translate

        public void translate​(float tx)
      • translate

        public void translate​(RPoint t)
        Apply a translation to the matrix, given a point.
        Parameters:
        t - vector translation
      • rotate

        public void rotate​(float angle,
                           float vx,
                           float vy)
        Apply a rotation to the matrix, given an angle and optionally a rotation center.
        Parameters:
        angle - the angle of rotation to be applied
        vx - the x coordinate of the center of rotation
        vy - the y coordinate of the center of rotation
      • rotate

        public void rotate​(float angle)
      • rotate

        public void rotate​(float angle,
                           RPoint v)
        Apply a rotation to the matrix, given an angle and optionally a rotation center.
        Parameters:
        angle - the angle of rotation to be applied
        v - the position vector of the center of rotation
      • scale

        public void scale​(float sx,
                          float sy,
                          float x,
                          float y)
        Apply a scale to the matrix, given scaling factors and optionally a scaling center.
        Parameters:
        sx - the scaling coefficient over the x axis
        sy - the scaling coefficient over the y axis
        x - x coordinate of the position vector of the center of the scaling
        y - y coordinate of the position vector of the center of the scaling
      • scale

        public void scale​(float sx,
                          float sy)
      • scale

        public void scale​(float s,
                          float x,
                          float y)
        Apply a scale to the matrix, given scaling factors and optionally a scaling center.
        Parameters:
        s - the scaling coefficient for a uniform scaling
        x - x coordinate of the position vector of the center of the scaling
        y - y coordinate of the position vector of the center of the scaling
      • scale

        public void scale​(float sx,
                          float sy,
                          RPoint p)
        Apply a scale to the matrix, given scaling factors and optionally a scaling center.
        Parameters:
        sx - the scaling coefficient over the x axis
        sy - the scaling coefficient over the y axis
        p - the position vector of the center of the scaling
      • scale

        public void scale​(float s,
                          RPoint p)
        Apply a scale to the matrix, given scaling factors and optionally a scaling center.
        Parameters:
        s - the scaling coefficient for a uniform scaling
        p - the position vector of the center of the scaling
      • scale

        public void scale​(float s)
      • skewX

        public void skewX​(float angle)
        Use this to apply a skewing to the matrix.
        Parameters:
        angle - skewing angle
      • skewY

        public void skewY​(float angle)
      • shear

        public void shear​(float shx,
                          float shy)
        Use this to apply a shearing to the matrix.
        Parameters:
        shx - x coordinate shearing
        shy - y coordinate shearing