Matrix transformations: Man i should have stayed awake in Trig…
Posted by: Todd in flash, flex, grrrrrrDear Mr. Cralle (my trigonometry teacher): You were right. The unit circle IS important to my life.
I’m working on a project where I’m trying to skew a component (an Image, actually) by an amount set by the user. But I’m running into problems with the skew amount calculation…
The actual project is much more complex, but I could replicate by problem in this simple example. I’m assuming something either in [ my understanding of the Matrix(), the way I’m calculating the offset, or the trig functions I’m using] are where it’s messing up, but I can’t figure it out.
A cookie for anyone who solves the problem…
Okay. The demo is here, and the source is here.
The blue canvas, on the left, is the source of the image I’m trying to skew. I’m drawing it, on the right, with two Image components. The slider says how far the right half should be moved up or down (as a percentage of the height of the right half)… and the left half should stay put but skew so that its right edge matches up with the right half.
It’s almost working, but the edges do not line up. The right half IS deflecting the proper amount, and from what I can tell, I’m doing the math right…
Anyone care to comment as to what’s wrong?
Sorry, Mr. Cralle…



Entries (RSS)
October 31st, 2007 at 12:07 pm
The skew component in the matrix should be the tangent, so drop the atan…
var leftMatrix:Matrix = new Matrix( 1, (amount.value * 100) / 50, 0, 1, 0, 0 );October 31st, 2007 at 12:35 pm
Thanks! Works like a charm. Wherever I was reading (should probably go find that) said atan() and so I started off all wrong. Works like a charm. Thanks a bunch!