JavaFX Rotation

Rotation can be defined as the process of rotating an object by a certain angle θ (theta). In JavaFX, the class javafx.scene.transform.Rotate represents the Rotation transform.

The image illustrates the rotation transform. the rectangle shown in the image is rotated along the Y-axis by the angle θ. The coordinates of the rectangle gets changed due to the rotation while the edges remains of the same length.


JavaFX Rotation

Properties

The properties of the class along with the setter methods are described in the following table.

Property Description Setter Methods
angle It is a double type property. It represents the angle of rotation in degrees. setAngle(double value)
axis It is a object type property. It represents the axis of rotation. setAxis(Point3D value)
pivotX It is a double type property. It represents the X coordinate of rotation pivot point. setPivotX(double value)
pivotY It is a double type property. It represents the Y coordinate of rotation pivot point. setPivotY(double value)
pivotZ It is a double type property. It represents the Z coordinate of rotation pivot point. setPivotZ(double value)

Constructors

The class contains six constructors.

  1. public Rotate() : creates the rotate transform with the default parameters.
  2. public Rotate(double angle) : creates the rotate transform with the specified angle measured in degrees. Pivot points are set to (0,0).
  3. public Rotate(double angle, Point3D axis) : creates the 3D rotate transform with the specified transform. Pivot points are set to (0,0,0).
  4. public Rotate(double angle, double pivotX, double pivotY) : creates the Rotate transform with the specified angle and pivot coordinate (x,y).
  5. public Rotate(double angle, double pivotX, double pivotY, double pivotZ) : creates the Rotate transform with the specified angle and 3D pivot coordinate (x,y,z).
  6. public Rotate(double angle, double pivotX, double pivotY, double pivotZ,Point3D Axis) : creates a 3D Rotate transform with the specified angle and pivot coordinate (x,y,z).

Example:

The following example illustrates the implementation of Rotation transform. Here, we have created two rectangles. One is filled with the lime-green color while the other is filled with the dark-grey color. The dark-grey rectangle is rotated with the angle 30 degree along the pivot point coordinates (100,300).


JavaFX Rotation
Next TopicJavaFX Scaling




Contact US

Email:[email protected]

JavaFX Rotation
10/30