/** * Sets this transformation to be a rotation around the origin. * A positive rotation angle corresponds * to a counter-clockwise rotation. * The transformation matrix for a rotation * by an angle <tt>theta</tt> * has the value: * <blockquote><pre> * | cos(theta) -sin(theta) 0 | * | sin(theta) cos(theta) 0 | * | 0 0 1 | * </pre></blockquote> * * @param theta the rotation angle, in radians * @return this transformation, with an updated matrix */ public AffineTransformation setToRotation(double theta) { setToRotation(Math.sin(theta), Math.cos(theta)); return this; }
/** * Sets this transformation to be a rotation * around a given point (x,y). * A positive rotation angle corresponds * to a counter-clockwise rotation. * The transformation matrix for a rotation * by an angle <tt>theta</tt> * has the value: * <blockquote><pre> * | cosTheta -sinTheta x-x*cos+y*sin | * | sinTheta cosTheta y-x*sin-y*cos | * | 0 0 1 | * </pre></blockquote> * * @param theta the rotation angle, in radians * @param x the x-ordinate of the rotation point * @param y the y-ordinate of the rotation point * @return this transformation, with an updated matrix */ public AffineTransformation setToRotation(double theta, double x, double y) { setToRotation(Math.sin(theta), Math.cos(theta), x, y); return this; }
/** * Creates a transformation for a rotation * by an angle <i>theta</i>, * specified by the sine and cosine of the angle. * This allows providing exact values for sin(theta) and cos(theta) * for the common case of rotations of multiples of quarter-circles. * * @param sinTheta the sine of the rotation angle * @param cosTheta the cosine of the rotation angle * @return a transformation for the rotation */ public static AffineTransformation rotationInstance(double sinTheta, double cosTheta) { AffineTransformation trans = new AffineTransformation(); trans.setToRotation(sinTheta, cosTheta); return trans; }
/** * Creates a transformation for a rotation * about the point (x,y) by an angle <i>theta</i>, * specified by the sine and cosine of the angle. * This allows providing exact values for sin(theta) and cos(theta) * for the common case of rotations of multiples of quarter-circles. * * @param sinTheta the sine of the rotation angle * @param cosTheta the cosine of the rotation angle * @param x the x-ordinate of the rotation point * @param y the y-ordinate of the rotation point * @return a transformation for the rotation */ public static AffineTransformation rotationInstance(double sinTheta, double cosTheta, double x, double y) { AffineTransformation trans = new AffineTransformation(); trans.setToRotation(sinTheta, cosTheta, x, y); return trans; }