The rotate function of transforms takes an x and a y coordinate where you can specify which point you want to rotate around. I'm not sure why you want to do the rotation first. It'd be easier to translate to your desired position, scale, then rotate. You can operate on scale and rotate independently but rotating affects the same positions in the matrix as scaling and translating; once you rotate, your original values for scaling and translating are lost.
Michael Bishop -----Original Message----- From: Paul L. Bogen [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 11, 2007 12:32 PM To: [email protected] Subject: RE: Rotation about center of a G But it will still rotate about the origin and not the center of the G, correct? plb -----Original Message----- From: Bishop, Michael W. CONTR J9C880 [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 11, 2007 9:37 AM To: [email protected] Subject: RE: Rotation about center of a G Transforms were a giant headache for me. The best way I found to deal with it was to apply the operations in this order: Translate, Scale, Rotate. If I wanted to "adjust" any of the values, I'd work backwards to that point. In order to translate, for instance, I'd revert the rotation angle, revert the scale, translate by the new values, then reapply the scale and rotation. It might not be the best way, but it was the only way I could find to allow the user to apply these operations arbitrarily. I don't even account for stretch/skew. I've got a utility class that helps with this stuff. Michael Bishop -----Original Message----- From: Paul L. Bogen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 10, 2007 12:13 PM To: [email protected] Subject: Rotation about center of a G I am trying to implement a function that translates a G to the origin, rotates it, translates it back to the original position, scales it, and then translates it to a target position. However it doesn't seem to work if I comment out the rotation bits translation and scaling work perfectly. Any ideas what I am doing wrong? <snip> SVGOMGElement svgG = ((SVGOMGElement) n); SVGTransformList svgTL = ((SVGTransformable) svgG).getTransform().getBaseVal(); svgTL.consolidate(); SVGMatrix svgM; if(svgTL.getNumberOfItems() == 0) { SVGTransform svgT = new SVGOMTransform(); svgM = new SVGOMMatrix(new AffineTransform(1,0,0,1,0,0)); svgT.setMatrix(svgM); svgTL.appendItem(svgT); } SVGOMMatrix mat1 = new SVGOMMatrix(new AffineTransform(1,0,0,1,-w/2,-h/2)); SVGOMMatrix mat2 = new SVGOMMatrix(new AffineTransform(Math.cos(angle),Math.sin(angle),-Math.sin(angle),Math.co s(angle),0,0)); SVGOMMatrix mat3 = new SVGOMMatrix(new AffineTransform(1,0,0,1,w/2,h/2)); SVGOMMatrix mat4 = new SVGOMMatrix(new AffineTransform(scaleX,0,0,scaleY,0,0)); SVGOMMatrix mat5 = new SVGOMMatrix(new AffineTransform(1,0,0,1,x,y)); svgM = mat1; svgM = svgM.multiply(mat2); svgM = svgM.multiply(mat3); svgM = svgM.multiply(mat4); svgM = svgM.multiply(mat5); svgTL.getItem(0).setMatrix(svgM); </snip> thanks, plb PAUL LOGASA BOGEN II Programmer KNOWLEDGE BASED SYSTEMS, INC. 1408 University Drive East College Station, Texas 77840 Phone: 979-260-5274 Fax: 979-691-2928 www.kbsi.com <file:///C:/Documents%20and%20Settings/plbogen/Application%20Data/Micros oft/Signatures/www.kbsi.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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
