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]

Reply via email to