3 Replies Latest reply on Feb 16, 2013 2:17 AM by KonradZuse

    Rotating a vector in JavaFX 2?

      With all those things in javafx.scene.transform like javafx.scene.transform.Rotate, is it possible to rotate single points? E.g. without JavaFX I did this:
      AffineTransform at = AffineTransform.getRotateInstance(Math.toRadians(90), 0, 0);
      Point2D rotatedNormal =  at.transform(new Point2D.Double(0,-1), null); // 12 clock reference vector
      This code first defines that I want to rotate by 90°, then it says what I want to rotate by those 90°: a vector (0,-1).

      In JavaFX 2 I am able to say I want to rotate by 90°:
      Rotate rotate = new Rotate(90, 0, 0); 
      but I don't know how to say which Point I want to rotate? Is the Rotate object only intended to be added to the Transforms of controls?

      Thanks :-)

      Edited by: srynoname on 15.02.2013 11:01
        • 1. Re: Rotating a vector in JavaFX 2?
          Java8 has a javafx.scene.transform.Rotate::transform function so you can do stuff like =>
          // rotate the point at (0, -1) 90 degrees clockwise.
          Point2D rotatedNormal = new Rotate(90).transform(0, -1); 
          There was a bunch of this basic math stuff added to Java8.

          http://javafx-jira.kenai.com/browse/RT-17401 "3D geometry support"
          http://javafx-jira.kenai.com/browse/RT-17942 "Provide Affine class with matrix manipulation methods (multiply, premultipy, negate, etc.)"
          https://wikis.oracle.com/display/OpenJDK/3D+Features "3D Features Planned for Version 8"
          • 2. Re: Rotating a vector in JavaFX 2?
            Thank you jsmith, so I'll stick with java.awt.geom.AffineTransform until Java 8 ;-) I was just wondering if this was really missing until now.
            • 3. Re: Rotating a vector in JavaFX 2?
              You can rotate on a single point in FX.


              That is what you are asking right? Rotating a vector along one of it's points?