views:

205

answers:

1

I mean, if I have an object and I apply 3 transforms to it, for example, suppose I don't know what each transform is doing, but I have the matrices.

So, I have

Object X > transform1 > transform2 > transform3 > final result

is there a way to obtain an Affine Transform that can represent the 3 transforms, so I can obtain the same result just doing one transform? For example

Object X > super transform > final result

where super transform = transform1 > transform2 > transform3

how do I do that on the iphone sdk using CGAffineTransform ?

thanks for any help.

+2  A: 

Have a look at CGAffineTransformConcat(). You can use this to combine two transformations. If you want to combine three transformations into one, something like this should work:

// Assumes you have CGAffineTransform transform1, transform2, transform3

CGAffineTransform finalTransform = CGAffineTransformConcat(CGAffineTransformConcat(transform1, transform2), transform3);
pix0r
OK thanks but if I combine N transforms on one and apply this one to my object will it be on the same place, position and size it would be if it had been transformed one by one by the N transforms?
Digital Robot
Yes, that's how it should work.
pix0r
You might need to be careful of the order in which you concatenate the transforms, so that you get the correct result.
Brad Larson