Class PolygonPerspectiveTransformation


  • public class PolygonPerspectiveTransformation
    extends java.lang.Object
    The perspective transformation can be expressed as a matrix multiplication: http://upload.wikimedia.org/math/d/6/5/d65e582afbf418e4989971cdee42a167.png. The transformation matrix of a polygon is defined by the transformation of the bounding box of the polygon. The general case where the four corners of the bounding box are translated can be reduced to the special case where only three corners are translated. Therefore this transformation algorithm will take the source and destination points in 2D space of the three corners that are moved.
    Author:
    andi
    • Field Detail

      • ORIGIN_ORIGIN

        private static final Translation2D ORIGIN_ORIGIN
      • point1

        private final javafx.beans.property.ObjectProperty<Translation2D> point1
      • point2

        private final javafx.beans.property.ObjectProperty<Translation2D> point2
      • point3

        private final javafx.beans.property.ObjectProperty<Translation2D> point3
      • a11

        private double a11
      • a12

        private double a12
      • a21

        private double a21
      • a22

        private double a22
      • b1

        private double b1
      • b2

        private double b2
    • Constructor Detail

      • PolygonPerspectiveTransformation

        public PolygonPerspectiveTransformation()
        Initializing the transormation by adding transformation listeners on the points.
    • Method Detail

      • calculate

        private void calculate()
        Recalculate the matrix values based on the points.
      • calculateA12

        private double calculateA12()
      • calculateA11

        private double calculateA11()
      • calculateB1

        private double calculateB1()
      • calculateA22

        private double calculateA22()
      • calculateA21

        private double calculateA21()
      • calculateB2

        private double calculateB2()
      • transform

        public javafx.scene.shape.Polygon transform​(javafx.scene.shape.Polygon polygon)
        Transform a polygon using the defined perspective transformation
        Parameters:
        polygon - untransformed polygon
        Returns:
        polygon with applied transformation.
      • convertToPoints

        private java.util.List<javafx.geometry.Point2D> convertToPoints​(javafx.collections.ObservableList<java.lang.Double> points)
      • point3Property

        public javafx.beans.property.ObjectProperty<Translation2D> point3Property()
      • point2Property

        public javafx.beans.property.ObjectProperty<Translation2D> point2Property()
      • point1Property

        public javafx.beans.property.ObjectProperty<Translation2D> point1Property()