Unity【Project——Beginner——Rotation】

个人笔记,来源unity官网教程

3D图形数学?点乘,欧拉角,四元数;

查手册查手册
Quaternion 手册描述

Project包含数个Tutorial

Tutorial —— Quaternions and Euler angles

Well, For starters, Quaternions are just how just Unity handles rotations. It’s a very effective way for rotations to occur in game development.(这是一个非常有效的旋转方式发生在游戏开发中。)It’s nothing to be afraid of , just know it’s how Unity handle rotations.
(草,真是体贴人意a,四元数什么的听起来就很难的样子,作者很贴心的说别怕2333)
在这里插入图片描述

These degrees, along the specific axis is the Euler Angle. (所以意思是,在这里设置的角度就都是欧拉角了)

What happening underneath the hood is that Unity is using Quaternions to handle the rotation and they’re representing it to us in an Euler Angle fashion because it’s just more readable. (原来如此吗,一个主外一个主内233)

Quaternions have an x, y, z and w rotation. But, because we are not really comfortable or familiar with the w rotation, Unity converts it to Euler Angles to be more readable.(w什么鬼

Now, with Quaternions it’s recommended that you always handle your rotations through Quaternions. You should never modify rotations using the Euler Angles and the reason of that is because of something called a Gimbal lock(万向锁).
Gimbal lock is the loss of one degree of freedom in a three dimensional 3 Gimbal mechanism.(万向节锁是在三维3万向节机构中失去一个自由度,,,说人话好吗)
That means that there are occasions where your y Euler Angle and your z Euler Angle may align and it will break the rotation.
(这意味着,在某些情况下,y Euler角和z Euler角可能对齐, waht?为什么会这样?)

To avoid gimbal lock we use Quaternions and then Unity will represent that Quaternion as an Euler Angle to you so that you can make sense of it.(emm

Tutorial——Quaternion Identity

在这里插入图片描述

And then typically what you’ll see here is when we instantiate an object, oftentimes we’ll type Quaternion.identity. And what this means is no rotation.

如果想要旋转角度的话

在这里插入图片描述

And if we look at the definition for Euler, it’s going to return a rotation

**

Tutorial——Quaternion Look Rotation

**
作用:we can specify one object to target or look at another object.

要让物体朝向另一个物体,需要一个方向,方向的公式就是direction = destination - source 目标物体的位置减我们的位置,返回值为Vector3
目标位置要如何取得,In order to get the sphere, i need a reference to it. So i’m going to create a variable type(变量) , Transform ,
to store the reference to that sphere. Using a serialized filed attribute, i can then assign it in the inspector.
在这里插入图片描述

然后把物体拖进来就行

在这里插入图片描述

access(访问) out current rotation. We assign(分配) it to the Quaternion look rotation method.
注释部分也叫pseudo code(伪代码),,Open parentheses(打开括号。。就是指看方法的重载) 填入方法参数叫pass in

**

Tutorial——Quaternion Slerp

**
Now Slerp is the equivalent of linear interpolation(线性插值等价), but spherically. And what that means that instead of just snapping to our target, If we use slerp with LookRotation , it would allow us to basically control going from point A to point B. So basically it would be able to smoothly , spherically interpolate between the current rotation to the target rotation. (就是让转动变得丝滑~)(不过为什么叫interpolate

在这里插入图片描述

第一步: We’re going to store this Look Rotation ,in a Quaternion variable.
第二步: Set it equal to Quaternion .slerp
第三 : current rotation=transform.rotation & target rotation=Look Rotation=direction to face.

所以说,方向终点minus起点得到一个Vector3 值,将这个 Vector3 代入Quaternion.LookRotation()再返回一个rotation
ps:文档对于LookRotation的描述:Creates a rotation with the specified forward and upwards directions.
而且 Quaternion are use to represent rotations
在这里插入图片描述

不用猜了,查文档,果然rotation就是四元数

结束

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本系统的研发具有重大的意义,在安全性方面,用户使用浏览器访问网站时,采用注册和密码等相关的保护措施,提高系统的可靠性,维护用户的个人信息和财产的安全。在方便性方面,促进了校园失物招领网站的信息化建设,极大的方便了相关的工作人员对校园失物招领网站信息进行管理。 本系统主要通过使用Java语言编码设计系统功能,MySQL数据库管理数据,AJAX技术设计简洁的、友好的网址页面,然后在IDEA开发平台中,编写相关的Java代码文件,接着通过连接语言完成与数据库的搭建工作,再通过平台提供的Tomcat插件完成信息的交互,最后在浏览器中打开系统网址便可使用本系统。本系统的使用角色可以被分为用户和管理员,用户具有注册、查看信息、留言信息等功能,管理员具有修改用户信息,发布寻物启事等功能。 管理员可以选择任一浏览器打开网址,输入信息无误后,以管理员的身份行使相关的管理权限。管理员可以通过选择失物招领管理,管理相关的失物招领信息记录,比如进行查看失物招领信息标题,修改失物招领信息来源等操作。管理员可以通过选择公告管理,管理相关的公告信息记录,比如进行查看公告详情,删除错误的公告信息,发布公告等操作。管理员可以通过选择公告类型管理,管理相关的公告类型信息,比如查看所有公告类型,删除无用公告类型,修改公告类型,添加公告类型等操作。寻物启事管理页面,此页面提供给管理员的功能有:新增寻物启事,修改寻物启事,删除寻物启事。物品类型管理页面,此页面提供给管理员的功能有:新增物品类型,修改物品类型,删除物品类型。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值