Class PolygonPerspectiveTransformation
- java.lang.Object
-
- ch.sahits.game.openpatrician.javafx.effects.transform.PolygonPerspectiveTransformation
-
public class PolygonPerspectiveTransformation extends java.lang.ObjectThe 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classPolygonPerspectiveTransformation.RecalculationEventListenerEnsure that the values are recalculated on property change.
-
Field Summary
Fields Modifier and Type Field Description private doublea11private doublea12private doublea21private doublea22private doubleb1private doubleb2private static Translation2DORIGIN_ORIGINprivate javafx.beans.property.ObjectProperty<Translation2D>point1private javafx.beans.property.ObjectProperty<Translation2D>point2private javafx.beans.property.ObjectProperty<Translation2D>point3
-
Constructor Summary
Constructors Constructor Description PolygonPerspectiveTransformation()Initializing the transormation by adding transformation listeners on the points.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcalculate()Recalculate the matrix values based on the points.private doublecalculateA11()private doublecalculateA12()private doublecalculateA21()private doublecalculateA22()private doublecalculateB1()private doublecalculateB2()private java.util.List<javafx.geometry.Point2D>convertToPoints(javafx.collections.ObservableList<java.lang.Double> points)Translation2DgetPoint1()Translation2DgetPoint2()Translation2DgetPoint3()javafx.beans.property.ObjectProperty<Translation2D>point1Property()javafx.beans.property.ObjectProperty<Translation2D>point2Property()javafx.beans.property.ObjectProperty<Translation2D>point3Property()voidsetPoint1(Translation2D value)voidsetPoint2(Translation2D value)voidsetPoint3(Translation2D value)javafx.scene.shape.Polygontransform(javafx.scene.shape.Polygon polygon)Transform a polygon using the defined perspective transformation
-
-
-
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
-
-
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)
-
getPoint3
public Translation2D getPoint3()
-
setPoint3
public void setPoint3(Translation2D value)
-
point3Property
public javafx.beans.property.ObjectProperty<Translation2D> point3Property()
-
getPoint2
public Translation2D getPoint2()
-
setPoint2
public void setPoint2(Translation2D value)
-
point2Property
public javafx.beans.property.ObjectProperty<Translation2D> point2Property()
-
getPoint1
public Translation2D getPoint1()
-
setPoint1
public void setPoint1(Translation2D value)
-
point1Property
public javafx.beans.property.ObjectProperty<Translation2D> point1Property()
-
-