Sunday 15 July 2012

java - Why Does AffineTransform Scale When Rotating -



java - Why Does AffineTransform Scale When Rotating -

it's more math problem, why method fail?

public void test() { affinetransform transform = affinetransform.getrotateinstance(1); system.out.println("scalex = " + transform.getscalex() + ", " + "scaley = " + transform.getscaley()); assert.assertequals(1, transform.getscalex(), 0.001); // fails assert.assertequals(1, transform.getscaley(), 0.001); // fails, }

the output is: scalex = 0.5403023058681398, scaley = 0.5403023058681398

just looking @ i'd scaling should not alter while rotating.

the scalex , scaley values getting cos(1 rad) correct.

they not represent scale of object after applying affine transformation. per this documentation, scalex contribution of initial x coordinate before transform final x coordinate after transform. same goes scaley. doesn't mean x1 = x0*scalex, x1 = x0*scalex + y0*m01y + m02.

to assert there no scaling done, can matrix values of transformation , determinant. if there no scale or shear, determinant 1. furthermore 2 components representing displacement should 0.

double[] m = transform.getmatrix() assert.assertequals(1, m[0]*m[4] - m[1]*m[3], 0.001) assert.assertequals(0, m[2], 0.001); assert.assertequals(0, m[5], 0.001);

java awt affinetransform

No comments:

Post a Comment