CGAffineTransformTranslate 含义以及转换过程中设置的值
我见过各种进行仿射变换的代码,它们往往总是 使用一些坐标值调用 CGAffineTransformTranslate。
典型的代码如下所示:
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0);
Apple 文档在 CGAffineTransformTranslate 上说,
您使用此函数来创建一个新的 通过添加平移进行仿射变换 现有仿射值 转换。由此产生的结构 代表一个新的仿射变换, 您可以使用(并重复使用,如果您 想要)移动坐标系。
我尝试过 tx 和 ty 的不同值,但有人能说出它的实际含义吗?也就是说,如果我输入 80、100,那么与输入 20、40 相比到底意味着什么?
I've seen various pieces of code that does Affine transformation and they tend to always
invoke CGAffineTransformTranslate with some coordinate values.
Typical code looks like:
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0);
Apple doc's on CGAffineTransformTranslate says,
You use this function to create a new
affine transform by adding translation
values to an existing affine
transform. The resulting structure
represents a new affine transform,
which you can use (and reuse, if you
want) to move a coordinate system.
I've played around with different values for tx and ty but can someone tell what it actually means? That is, if I put in 80, 100, then what does that exactly mean in comparison to putting in 20, 40?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
翻译意味着四处走动。应用旋转和缩放后,包含 (80; 100) 平移分量的仿射变换将在 X 轴和 100 轴上将其变换的任何内容(例如向量、点)移动 80 度。
1 的翻译意味着完全不同的故事。它可能是 1 个像素,也可能是某个任意单位,具体取决于所使用的投影变换(如果是 3D)。
Translation means moving around. An affine transform that includes a (80; 100) translation component will move whatever is transformed by it (e.g. vector, point) by 80 on the X axis and 100 axis, after rotation and scaling are applied.
What a translation of 1 means is a different story altogether. It might be 1 pixel, or some arbitrary unit dependent on the projection transform used (if talking 3D).