Unity【Project——Beginner——Rotation】

本文是个人学习Unity官方教程的笔记,主要涉及四元数(Quaternion)与欧拉角(Euler angles)的概念。教程解释了Unity如何使用四元数处理旋转,并建议直接使用四元数避免万向节锁问题。还介绍了Quaternion.identity表示无旋转,Quaternion.LookRotation用于指定物体朝向另一物体,以及Quaternion.Slerp实现平滑旋转过渡的方法。

个人笔记,来源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就是四元数

结束

源码直接下载地址: https://pan.quark.cn/s/a4b39357ea24 USB 眼图检测手段 本资源主要阐述了运用示波器检测 USB 眼图以及时序的检测手段,意在辅助测试工程师独立实施检测。以下是该检测手段的详细知识要点: 一、检测所需仪器设备 * 一台泰克 MSO 70404C 示波器,配备 1 条 P7340A(差分式)和 1 条 P7240(单端式)探针 * 一个 USB 检测夹具(泰克提供) * 三条 USB 线缆,其中 2 条为 A 口转 B 口型的 USB 线缆,另外 1 条为标准的 micro USB 数据线缆 * 一台个人电脑(建议使用笔记本电脑),预装 XHCI HSETT 检测软件 二、USB 眼图检测流程 1. 将差分探针连接至示波器的 CH1 通道,然后将差分探针的另一端连接至 USB 检测夹具上 J310 接口的中间两个引脚(留意正负极的连接)。 2. 通过 2 条 USB 线缆(A 口转 B 口型)将夹具上的 J35 和 J37 接口分别接入笔记本电脑的两个 USB 接口,夹具上的 J35 为供电接口,J37 为数据传输接口。 3. 使用 micro USB 线缆将夹具上的 J34 位置的 A 型 USB 接口与手机相连接,确保手机设置中已开启 USB 调试功能。 4. 将夹具上的单刀双掷开关(S6),调整至下方位置(INIT 红灯点亮)。 5. 检测线路的连接方式如图 1 所示。 6. 启动电脑上的 XHCI HSETT 软件后,点击 TEST 按钮进行操作,若手机与电脑均通过 USB 线缆正常连接至夹具,select device 框中将显示识别到的手机设备。 7. 在 Device Co...
打开链接下载源码: https://pan.quark.cn/s/9b2c3f4a311b 在信息技术领域的界面设计及开发范畴内,对用户界面(UI)进行优化是一项核心的技能,特别是在网页设计工作中,按钮(Button)作为交互设计的基础构成部分,其外观设计直接关联到用户的使用感受和网站的整体视觉美感。本文将详细阐释如何借助层叠样式表(CSS)来个性化按钮的样式,使其更具活力和吸引力。 ### 一、基础原理:CSS与按钮样式 CSS是一种用于规定网页文档布局及外观的语言,它使开发者能够调控页面元素的表现形式,涵盖色彩、字体、尺寸、定位等要素。对于按钮设计而言,CSS可用于设定其形态、尺寸、色彩、边框、背景以及鼠标悬停或点击时的动态效果,从而提升用户界面的互动性和视觉吸引力。 ### 二、样式详细解析 #### 1. `.btn` 样式 - **边框设定**:采用1像素宽的`#7b9ebd`色实线边框。 - **内边距配置**:在各个方向均设置2像素的间距。 - **字体尺寸设定**:字号为12像素。 - **背景渐变设置**:运用IE专用的滤镜实现从白色至`#cecfde`的渐变。 - **光标形态**:当鼠标指针移至按钮时,光标转变为手形图标。 - **文字色彩**:文本颜色为黑色。 #### 2. `.btn1_mouseout` 样式 这是`.btn`在鼠标未悬停情境下的样式表现,主要变更在于边框及背景渐变的色彩: - **边框设定**:边框颜色调整为`#7EBF4F`。 - **背景渐变设置**:渐变色彩从白色过渡至`#B3D997`。 #### 3. `.btn1_mouseover` 样式 该样式应用于鼠标指针悬停在按钮之上时: - **边框设定**:与`...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值