不知道什么这些xx
和xy
和所有其他类似的成员意味着什么,但我的猜测*是,你将无法追溯仅使用这些值应用的转换(它会像追溯1+2+3+4
只知道你从1
开始,最后是10
- 我想*)。
在这种情况下,我的建议是从CGAffineTransform
导出和存储所需的值,但因为它是一个结构,你不能这样做,所以在我看来,你最好的选择就是写一个包装类,像这样:
class MyTransform
{
//wrapped transform structure
private CGAffineTransform transform;
//stored info about rotation
public float Rotation { get; private set; }
public MyTransform()
{
transform = CGAffineTransform.MakeIdentity();
Rotation = 0;
}
public void Rotate(float angle)
{
//rotate the actual transform
transform.Rotate(angle);
//store the info about rotation
Rotation += angle;
}
//lets You expose the wrapped transform more conveniently
public static implicit operator CGAffineTransform(MyTransform mt)
{
return mt.transform;
}
}
现在定义操作,您可以使用这个类是这样的:
//do Your stuff
MyTransform t = new MyTransform();
t.Rotate(angle);
view.Transform = t;
//get the rotation
float r = t.Rotation;
//unfortunately You won't be able to do this:
float r2 = view.Transform.Rotation;
,你可以看到这种方法也有它的局限性,但您可以随时使用的MyTransform
只有一个实例应用所有这样转换rts并将该实例存储在某处(或者可能是这种转换的集合)。
您可能还需要存储/揭露其他变换一样规模或在MyTransform
类翻译,但我相信你会知道在哪里可以从这里走。
* 随时纠正我,如果我错了
你的方法是坚实的,正是我会去了。但是如果任何人有任何光线照射在这个问题上自由! – LampShade 2013-02-10 20:09:43