I think it is. I'll smile, nod, pretend I understand how it works and check it out. It looks like I'll need to convert radians to degrees because I think the rotate parameter wants degrees, but I'm sure there's an easy way to do that. Thanks a bunch, I'll give this a try.
Michael Bishop -----Original Message----- From: Archie Cobbs [mailto:[EMAIL PROTECTED] Sent: Thursday, December 08, 2005 1:21 PM To: [email protected] Subject: Re: Scaling around a center point... Bishop, Michael W. CONTR J9C880 wrote: > transform="translate(x, y) scale(x, y) rotate(t)" > > Is there a way to get the value of t? Here's a method I wrote to do this. Not sure if it's what you need but perhaps it could be a start (no guarantees :-). /** * Compute the rotation angle of an affine transformation. * Counter-clockwise rotation is considered positive. * * @return rotation angle in radians (beween -pi and pi), * or NaN if the transformation is bogus. */ public static double getRotationAngle(AffineTransform transform) { // Eliminate any post-translation transform = (AffineTransform)transform.clone(); transform.preConcatenate(AffineTransform.getTranslateInstance( -transform.getTranslateX(), -transform.getTranslateY())); // Apply transformation to a vector Point2D v1 = new Point2D.Double(1, 0); Point2D v2 = transform.transform(v1, null); // Compute dot product double dotProduct = v1.getX() * v2.getX() + v1.getY() * v2.getY(); // Compute positive angle double angle = Math.acos(dotProduct / (v1.distance(0, 0) * v2.distance(0, 0))); // Negate angle if rotation direction is clockwise if (v2.getY() < 0) angle = -angle; // Done return angle; } -Archie ________________________________________________________________________ __ Archie Cobbs * CTO, Awarix * http://www.awarix.com -- ________________________________________________________________________ __ Archie Cobbs * CTO, Awarix * http://www.awarix.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
