Reputation: 113
I'm getting started with JavaFX and am struggling with the way that transforms are handled. I understand that you can add various transforms to a node but I want to be able to accumulate the transforms due to user interaction with nodes.
I'm able to create a 2D affine transformation matrix for the transform i want to perform. eg:
| a b c |
| d e f |
| g h i |
The JavaFX affine transform is defined as:
| mxx mxy mxz tx |
| myx myy myz ty |
| mzx mzy mzz tz |
My question is: How do I convert the transformation matrix to the JavaFX affine transform?
Upvotes: 0
Views: 1207
Reputation: 758
What you have is a projective transformation matrix for a 2D space and JavaFX expects one for a 3D space.
Assuming you don't have any projections (since you want a 2D affine transformation), your matrix should look like:
| mxx mxy tx |
| myx myy ty |
| 0 0 1 |
For the other parameters you have mzz = 1
and mxz = myz = mzx = mzy = tz = 0
.
Therefore, the JavaFX matrix (using your original notation) should look like:
| a b 0 c |
| d e 0 f |
| 0 0 1 0 |
| 0 0 0 1 |
Edit: I think when you have non-affine transformations, the JavaFx matrix should look like:
| a b 0 c |
| d e 0 f |
| 0 0 1 0 |
| g h 0 i |
Upvotes: 1