• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Help with understanding matrices
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with understanding matrices


  • Subject: Re: Help with understanding matrices
  • From: Simon Topliss <email@hidden>
  • Date: Thu, 14 Feb 2008 19:13:10 +0000

On 14 Feb 2008, at 13:04, deivy petrescu wrote:

If I rotate the image by 45 degrees clockwise, the matrix is now:

{class:matrix, mvalue_a:0.707106769085, mvalue_b:-0.707106769085, mvalue_c:-0.707106769085, mvalue_d:-0.707106769085, mvalue_tx:-1.14441533203125E+4, mvalue_ty:821.1611328125}

This is kind of weird. You rotate clockwise and anti-clockwise and get the same result (the sign of b,c and d are negative in both cases)

Apologies, Deivy, I think that should have read "45 degrees anti- clockwise" above.


OK Simon, I believe I know why the values of angles change. It does so that you can find out the scaling. The angle is found by its tangent.
But, before I give you a way to find the angle and the scaling, could you scale by an amount different than 50%?
Try 40%, 30%, 70% and 150% say.
So, the matrix is bogus, but the idea is clever.


30% scaling, no rotation: {class:matrix, mvalue_a:0.300000011921, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:-0.300000011921, mvalue_tx:-1984.0, mvalue_ty:2925.3828125}

40% scaling, no rotation: {class:matrix, mvalue_a:0.40000000596, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:-0.40000000596, mvalue_tx:-2786.0, mvalue_ty:3801.51025390625}

70% scaling, no rotation: {class:matrix, mvalue_a:0.699999988079, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:-0.699999988079, mvalue_tx:-5192.0, mvalue_ty:6429.892578125}

150% scaling, no rotation: {class:matrix, mvalue_a:1.5, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:-1.5, mvalue_tx:-1.1608E+4, mvalue_ty: 1.34389130859375E+4}

30% scaling, 45 degrees rotation: {class:matrix, mvalue_a: 0.212132036686, mvalue_b:-0.212132036686, mvalue_c:-0.212132036686, mvalue_d:-0.212132036686, mvalue_tx:-3137.84619140625, mvalue_ty: 454.24853515625}

40% scaling, 45 degrees rotation: {class:matrix, mvalue_a: 0.282842725515, mvalue_b:-0.282842725515, mvalue_c:-0.282842725515, mvalue_d:-0.282842725515, mvalue_tx:-4324.4609375, mvalue_ty: 506.66455078125}

70% scaling, 45 degrees rotation: {class:matrix, mvalue_a: 0.494974732399, mvalue_b:-0.494974732399, mvalue_c:-0.494974732399, mvalue_d:-0.494974732399, mvalue_tx:-7884.30712890625, mvalue_ty: 663.91259765625}

150% scaling, 45 degrees rotation: {class:matrix, mvalue_a: 1.060660123825, mvalue_b:-1.060660123825, mvalue_c:-1.060660123825, mvalue_d:-1.060660123825, mvalue_tx:-1.737723046875E+4, mvalue_ty: 1083.2412109375}

The values are defined as:

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)

Mark helped enormously by getting me nearly there with his last post.

I've modified it a little to also return the x and y skew values.

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

I haven't had time to fully test if it works in all cases yet. The value returned for 30% scaling, 45 degrees rotation are {-45.0, 0.300000003295, -0.300000003295, -135.0, -45.0}.

However, as the image hasn't actually been manually skewed in Illustrator, I'm still trying to figure out how to work what to do with this extra data.

Realising my complete lack of knowledge in this area, I've ordered a couple of Mathematics for Computer Graphics books from Amazon!

Thanks for your continued interest and help,

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
  • Follow-Ups:
    • Re: Help with understanding matrices
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Help with understanding matrices (From: Simon Topliss <email@hidden>)
 >Re: Help with understanding matrices (From: Doug McNutt <email@hidden>)
 >Re: Help with understanding matrices (From: Simon Topliss <email@hidden>)
 >Re: Help with understanding matrices (From: deivy petrescu <email@hidden>)

  • Prev by Date: Re: Applescript "Excessively" Slow in Leopard
  • Next by Date: Re: VBA to Applescript
  • Previous by thread: Re: Help with understanding matrices
  • Next by thread: Re: Help with understanding matrices
  • Index(es):
    • Date
    • Thread