//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Returns a transform that rotates coordinates around an anchor * point accordinate to a rotation vector. * All coordinates rotate about the specified anchor coordinates * by the same amount. * The amount of rotation is such that coordinates along the former * positive X axis will subsequently align with the vector pointing * from the origin to the specified vector coordinates. * If both <code>vecx</code> and <code>vecy</code> are 0.0, * an identity transform is returned. * This operation is equivalent to calling: * <pre> * AffineTransform.getRotateInstance(Math.Atan2(vecy, vecx), * anchorx, anchory); * </pre> * * @param vecx the X coordinate of the rotation vector * @param vecy the Y coordinate of the rotation vector * @param anchorx the X coordinate of the rotation anchor point * @param anchory the Y coordinate of the rotation anchor point * @return an <code>AffineTransform</code> object that rotates * coordinates around the specified point according to the * specified rotation vector. */ public static AffineTransform GetRotateInstance(double vecx, double vecy, double anchorx, double anchory) { var tx = new AffineTransform(); tx.SetToRotation(vecx, vecy, anchorx, anchory); return tx; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Returns a transform representing a rotation transformation. * The matrix representing the returned transform is: * <pre> * [ Cos(theta) -Sin(theta) 0 ] * [ Sin(theta) Cos(theta) 0 ] * [ 0 0 1 ] * </pre> * Rotating by a positive angle theta rotates points on the positive * X axis toward the positive Y axis. * also the discussion of * <a href="#quadrantapproximation">Handling 90-Degree Rotations</a> * above. * @param theta the angle of rotation measured in radians * @return an <code>AffineTransform</code> object that is a rotation * transformation, created with the specified angle of rotation. */ public static AffineTransform GetRotateInstance(double theta) { var tx = new AffineTransform(); tx.SetToRotation(theta); return tx; }