Re: Help with understanding matrices
Re: Help with understanding matrices
- Subject: Re: Help with understanding matrices
- From: Simon Topliss <email@hidden>
- Date: Fri, 15 Feb 2008 14:20:40 +0000
On 14 Feb 2008, at 21:07, Mark J. Reed wrote:
This page has a good overview of matrix transforms - it's about Flash,
but it uses the same Adobe-standard terminology:
http://www.senocular.com/flash/tutorials/transformmatrix/
Yes, I've read that. That's where I came up with the modified handler
that uses the format below.
mvalue_a = x scale
mvalue_b = y skew
mvalue_c = x skew
mvalue_d = y scale
mvalue_tx = x translation (position)
mvalue_ty = y translation (position)
Ok, you're mixing up interpretations here. The first four values in
the matrix represent a combination of scaling with *either* skew or
rotation. You can consider either the skew or the rotation as the
primary value and the other one is the result of combining it with the
scale. But it doesn't make sense to try and extract both rotation and
skew from a matrix... you'll get two values that depend on each other.
Probably. I'm pretty poor at math!
I think I understand. But what I'm still not sure about is what if an
object has been scaled, rotated and skewed along one axis (e.g
horizontally skewed)?
This matrix represents an image that is at 100%, but has been
horizontally skewed 12 degrees, then rotated 45 degrees.
{class:matrix, mvalue_a:0.707106769085, mvalue_b:-0.707106769085,
mvalue_c:-0.556806564331, mvalue_d:-0.857406973839,
mvalue_tx:-1.012733203125E+4, mvalue_ty:2137.982421875}
Rotating and skewing an image isn't common, but I'd like to get the
handler nailed-down for all instances.
For example:
set {theta_deg, hscale, vscale, hskew, vskew} to
decode_matrix({mvalue_a:0.707106769085, mvalue_b:-0.707106769085,
mvalue_c:-0.556806564331, mvalue_d:-0.857406973839,
mvalue_tx:-1.012733203125E+4, mvalue_ty:2137.982421875})
log -- (*-38.21843067341, 0.900018629234, -1.091323521466,
-128.21843067341, -38.21843067341*)
on decode_matrix(mat)
set _a to mvalue_a of mat
set _b to mvalue_b of mat
set _c to mvalue_c of mat
set _d to mvalue_d of mat
set theta to atan2 {_c, _a}
set cos_theta to cos (theta)
set hscale to _a / cos_theta
set vscale to _d / cos_theta
set hskew to 180 / pi * theta - 90
set vskew to 180 / pi * theta
set theta_deg to theta / pi * 180
return {theta_deg, hscale, vscale, hskew, vskew}
end decode_matrix
Ideally, what I want the handler to return would be {45.0, 100.0,
100.0, 12.0, 0.0}. So I guess some other calculations are going to be
required?
Simon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden