需要更好,更简单地理解CATransform3D [英] Need better and simpler understanding of CATransform3D

查看:166
本文介绍了需要更好,更简单地理解CATransform3D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请浏览图片。


所以这是我从一些在线资源获得的代码,它确实改变了我的对象。除此之外,我什么都不懂。我是CATransform3D的新手,想知道它是如何工作的。

So this is the code which I got from some online source and it does transform my object. Besides that, I understood nothing at all. I am new to CATransform3D and want to know exactly how it works.

CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -500;
transform = CATransform3DRotate(transform, 45.0f * M_PI / 180.0f, 0, 1, 0.0f);
_bgView.layer.transform = transform;

我想知道这段代码是如何运行的?
为什么我们在m34中设置了一些值?我发现它的某种矩阵甚至让我更加困惑。此外, CATransform3DRotate 中的参数是什么意思?

I want to know how did this code run? Why did we set some value in m34? I found that its some kind of matrix which even confuses me more. Also, what do the arguments in the CATransform3DRotate mean???

我试图理解但没有进一步。

I am trying to understand but not getting any further.

我想深入了解CATransform3D。请帮助处理任何文章,文档或解释自己。

I want a deep understanding of CATransform3D. Please help with any articles, documentation or by explaining yourselves.

非常感谢。

推荐答案

我不确定是什么 m34 无需查看。

I'm not sure what m34 is without looking.

2D旋转很简单,因为它只需要一个可以旋转的角度。然后围绕Z轴(即直接指向屏幕的轴)完成旋转。

A 2D rotation is easy because all it needs is an angle by which to rotate. The rotation is then done AROUND the Z axis (i.e. the axis that points directly out of the screen).

3D旋转不同。它需要一个角度,但它需要知道你在哪个轴(或多个轴)旋转。

A 3D rotation is different. It needs an angle but also it needs to know which axis (or axes) you are rotating around.

CATransform3DRotate 你给它五个参数......

In CATransform3DRotate you give it five parameters...


  1. 你想要将轮换应用到的转换。

  2. 角度(以弧度表示)π弧度= 180度
    3,4和5是应用于每个轴的角度旋转的多少。

  1. The transform that you want to apply the rotation to.
  2. Angle (in radians) π radians = 180 degrees 3, 4 and 5 are how much of the angle rotation to apply to each axis.

X轴 - 这是从屏幕左侧到屏幕右侧的轴。

X axis - this is the axis that goes from the left of the screen to the right of the screen.

您在示例中应用的轮换如下...

The rotation you have applied in your example is as follows...

angle = 45度(转换成弧度)。
X = 0
Y = 1
Z = 0

angle = 45 degrees (converted into radians). X = 0 Y = 1 Z = 0

这意味着所有45度将围绕Y旋转轴。也就是说,它会像一个旋转门一样围绕着它的中间线旋转。

This means that all of the 45 degrees will be rotated around the Y axis. i.e. it will rotate like a revolving door around the line down its middle.

如果你有了参数......最后是1,0,0那么它会像桨船桨一样旋转。 离你而去。

If you had the params... "1, 0, 0" at the end then it would rotate like a paddle boat paddle. "Falling away from you."

最后,如果你有0,0,1,它会像屏幕上的凯瑟琳轮一样旋转。

Finally if you had "0, 0, 1" it would spin like a catherine wheel on the screen.

您还可以组合这些值,即使用0,1,1来应用围绕两个轴的旋转。

You can also combine the values i.e. have "0, 1, 1" to apply rotation about two axes.

w行矩阵是透视投影。您是否曾在学校进行透视绘图,在那里放置一个点并从点画线,然后画出适合这些线条的东西来给它透视?那么m34值决定了点的放置位置,因此提供了透视图。将它设置为类似-50的值,您会看到更大的差异。

The w row of the matrix is the perspective projection. Did you ever do perspective drawing at school where you place a dot and draw lines from the dot and then draw things to fit those lines to give it perspective? Well the m34 value determines where that dot is placed and so provides perspective. Set it to something like -50 and you will see a bigger difference.

设置m34与此点的Z轴值有关。所以这一点放在(0,0,-1 / 500)

Setting m34 relates to the Z axis value of this point. So the point is placed at (0, 0, -1/500)

这篇关于需要更好,更简单地理解CATransform3D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆