当前位置: 首页 > news >正文

阜宁有做网站的吗南宁网站seo

阜宁有做网站的吗,南宁网站seo,模版之家官网,深圳新闻第一线曝光热线前言:欧拉角和四元数的简单描述 我们在Inspector面板上看到的rotation其实是欧拉角, 我们将Inspector面板设置成Debug模式,此时看到的local Rotation才是四元数。 Unity中的欧拉旋转是按照Z-X-Y顺规执行的旋转,一组欧拉旋转过程中…

前言:欧拉角和四元数的简单描述

我们在Inspector面板上看到的rotation其实是欧拉角,

我们将Inspector面板设置成Debug模式,此时看到的local Rotation才是四元数。

Unity中的欧拉旋转是按照Z-X-Y顺规执行的旋转,一组欧拉旋转过程中,相对的轴向不会发生变化。 Transform.Rotate(new Vector3(30,60,30)),它代表执行了一组欧拉旋转,它相对的是旋转前的局部坐标朝向。正是这种顺规和轴向的定义,导致了万向节死锁的自然形成。

举个例子就是,在世界空间下,按照X-Y-Z去拖拽旋转轴,当拖拽到Z轴旋转时,X和Y轴的欧拉角都会改变,如果按照Z-X-Y去按顺序拖拽则轴与轴之间的数值不会影响。

代码表示:方式1和方式3的旋转结果相同

//方式一
transform.Rotate(30,60,30,Space.World);//方式二(X-Y-Z)
transform.Rotate(30,0,0,Space.World);
transform.Rotate(0,60,0,Space.World);
transform.Rotate(0,0,30,Space.World);//方式三(Z-X-Y)
transform.Rotate(0,0,30,Space.World);
transform.Rotate(30,0,0,Space.World);
transform.Rotate(0,60,0,Space.World);

欧拉角和四元数的相互转换:

// 欧拉角表示旋转
Vector3 eulerRotation = new Vector3(30f, 60f, 30f);
// 将欧拉角转换为四元数
Quaternion quaternionRotation = Quaternion.Euler(eulerRotation);
// 将四元数转换为欧拉角
Vector3 convertedEulerAngles = quaternionRotation.eulerAngles;

局部坐标系和世界坐标系的转换:

transform.up = transform.rotation * Vector3.up;
transform.right = transform.rotation * Vector3.right;
transform.forward = transform.rotation * Vector3.forward;

1.Transform旋转系列

(1)transform.Rotate(有万向锁

public void Rotate (Vector3 eulers, Space relativeTo= Space.Self);

public void Rotate (float xAngle, float yAngle, float zAngle, Space relativeTo= Space.Self);

描述:这两种方式的旋转结果相同,应用一个围绕 Z 轴旋转 zAngle 度、围绕 X 轴旋转 xAngle度、围绕 Y 轴旋转 yAngle 度(按此顺序)的旋转。Space.Self代表局部坐标系,Space.World代表世界坐标系。

public void Rotate (Vector3 axis, float angle, Space relativeTo= Space.Self);

描述:用给定角度定义的度数围绕给定轴旋转该对象。

我们可以看个这样的例子:

transform.Rotate(Vector3.up, 30, Space.Self);
transform.Rotate(transform.up, 30, Space.World);

这两种旋转方式的结果是一致的。

(2)transform.RotateAround(有万向锁

public void RotateAround (Vector3 axis, float angle);

public void RotateAround (Vector3 point, Vector3 axis, float angle);

描述:第一个参数为围绕的中心点,第二个参数为物体围绕转动的轴,方式1和方式2的区别在于,方式1围绕的中心点就是自己。

transform.RotateAround和transform.Rotate的区别就好比地球公转和自转的区别。

(3)transform.LookAt(无万向锁

public void LookAt (Transform target, Vector3 worldUp= Vector3.up);

public void LookAt (Vector3 worldPosition, Vector3 worldUp= Vector3.up);

描述:旋转变换,使向前矢量指向 target 的当前位置。

主要是这句话的理解:

“随后它会旋转变换以将其向上方向矢量指向 worldUp 矢量暗示的方向。 如果省略 worldUp 参数,则该函数会使用世界空间 y 轴。如果向前方向垂直于 worldUp,则旋转的向上矢量将仅匹配 worldUp 矢量。”

什么意思呢,就是LookAt的第一个参数决定了forward轴(蓝轴)的朝向,但是怎么旋转到目标位置还需要再确定一个轴,但是第二个参数并不等价于up轴(绿轴)指向worldUp,只是在保证forward轴(蓝轴)指向物体时,会尽量保证在旋转的过程中,up轴指向worldUp大致的方向,且不管怎么旋转up轴和worldUp夹角都不会超过90°。

2.Quaternion旋转系列(无万向锁

创建旋转:

(1)Quaternion.LookRotation

public Quaternion LookRotation (Vector3 forward, Vector3 upwards= Vector3.up);

描述:物体的Z 轴指向forward,X 轴指向 forward 和 upwards 的差积,Y 轴指向 Z 和 X 之间的差积对齐。确定轴的顺序是Z-X-Y的顺序。

与LookAt的区别:

LookAt()与LookRotation()的参数都相似,但前者是将游戏对象的z轴指向参数所表示的那个点,而后者是将游戏对象的z轴指向参数所表示的向量的方向。

transform.LookAt(targetCube.transform);
transform.rotation = Quaternion.LookRotation(targetCube.transform.position-transform.position);

这两行代码的效果是等价的。

(2)Quaternion.FromToRotation

public static Quaternion FromToRotation (Vector3 fromDirection, Vector3 toDirection);

描述:创建一个从 fromDirection 旋转到 toDirection 的旋转。

通常情况下,您使用该方法对变换进行旋转,使其的一个轴(例如 Y 轴)跟随世界空间中的目标方向 /toDirection/。

效果等价于Quaternion.SetFromToRotation

(3)Quaternion.AngleAxis

public static Quaternion AngleAxis (float angle, Vector3 axis);

描述:创建一个围绕 axis 旋转 angle 度的旋转。

下面是实现绕着世界Y轴自转的小案例

    private void Update(){transform.rotation=Quaternion.AngleAxis(Time.deltaTime*60,Vector3.up);}

效果预览:

操作旋转:

(4)Quaternion.Slerp

public static Quaternion Slerp (Quaternion a, Quaternion b, float t);

描述:在四元数 a 与 b 之间按比率 t 进行球形插值。参数 t 限制在范围 [0, 1] 内。

(5)Quaternion.RotateTowards

public static Quaternion RotateTowards (Quaternion from, Quaternion to, float maxDegreesDelta);

描述:将 from 四元数朝 to 旋转 maxDegreesDelta 的角度步长(但请注意, 该旋转不会过冲)。 如果 maxDegreesDelta 为负值,则向远离 to 的方向旋转,直到旋转 恰好为相反的方向。

与Quaternion.FromToRotation的区别:

RotateTowards是操作旋转,就是一点点的把from插值到to。而FromToRotation它代表的是一个完整的旋转过程,你需要提供一个起始旋转和目标旋转,方法将返回一个表示从起始方向到目标方向的旋转。

3.刚体旋转系列

(1)Rigidbody.MoveRotation

public void MoveRotation (Quaternion rot);

刚体插值在渲染的任意中间帧中的两个旋转之间平滑过渡,方法必须写在FixedUpdate,参数是四元数。相比于其他所有的旋转方式,他可以实现带动在平台上的物体一起旋转。

实现带动效果:旋转物的刚体必须要勾选isKinematic,切记。

代码如下:

    public float speed;private float angle;private Rigidbody rb;private void Start(){rb = GetComponent<Rigidbody>();}private void FixedUpdate(){angle = Time.fixedDeltaTime * speed;rb.MoveRotation(rb.rotation*Quaternion.Euler(Vector3.up*angle));}

(2)Rigidbody角速度angularVelocity

描述:表示刚体的角速度,即物体绕其自身轴旋转的速度。它是一个三维矢量,每个分量分别表示绕相应轴的旋转速度。

    private void Update(){//绕y轴匀速运动rb.angularVelocity = new Vector3(0, 3, 0);}

它也可以带动平台上的物体一起跟着旋转。

使用角速度需要注意的是,不能勾选isKinematic。

官方说不建议直接修改angularVelocity,会造成失真。但我没遇到过什么问题,我的理解是直接修改内部属性不太符合编程习惯,会破坏完整性。

参考链接:学习笔记3 - 简书


文章转载自:
http://faille.bpcf.cn
http://unconceivable.bpcf.cn
http://edie.bpcf.cn
http://dysgenics.bpcf.cn
http://pauperdom.bpcf.cn
http://pistology.bpcf.cn
http://iffish.bpcf.cn
http://deplumation.bpcf.cn
http://tonoscope.bpcf.cn
http://legate.bpcf.cn
http://sphygmography.bpcf.cn
http://kinky.bpcf.cn
http://identify.bpcf.cn
http://thinnish.bpcf.cn
http://citronella.bpcf.cn
http://convertibility.bpcf.cn
http://horatius.bpcf.cn
http://pragmatistic.bpcf.cn
http://plectra.bpcf.cn
http://sailplane.bpcf.cn
http://aoc.bpcf.cn
http://battery.bpcf.cn
http://office.bpcf.cn
http://sudanese.bpcf.cn
http://abdominous.bpcf.cn
http://farandole.bpcf.cn
http://dihydrate.bpcf.cn
http://thimerosal.bpcf.cn
http://thereamong.bpcf.cn
http://invitatory.bpcf.cn
http://misadventure.bpcf.cn
http://micrurgy.bpcf.cn
http://caddis.bpcf.cn
http://datable.bpcf.cn
http://biostrome.bpcf.cn
http://irrigate.bpcf.cn
http://zooman.bpcf.cn
http://myatrophy.bpcf.cn
http://collarette.bpcf.cn
http://synarchy.bpcf.cn
http://copernican.bpcf.cn
http://cosmogony.bpcf.cn
http://libertinage.bpcf.cn
http://currijong.bpcf.cn
http://bisegment.bpcf.cn
http://inferno.bpcf.cn
http://keratectomy.bpcf.cn
http://adman.bpcf.cn
http://ippf.bpcf.cn
http://fraze.bpcf.cn
http://syntheses.bpcf.cn
http://tickey.bpcf.cn
http://sepoy.bpcf.cn
http://supernova.bpcf.cn
http://moonlit.bpcf.cn
http://textbox.bpcf.cn
http://multigravida.bpcf.cn
http://anemone.bpcf.cn
http://taylorite.bpcf.cn
http://exopoditic.bpcf.cn
http://acclimatise.bpcf.cn
http://freehanded.bpcf.cn
http://infelicitous.bpcf.cn
http://japanning.bpcf.cn
http://turnsick.bpcf.cn
http://frostbitten.bpcf.cn
http://plait.bpcf.cn
http://jephthah.bpcf.cn
http://accommodate.bpcf.cn
http://bouquetiere.bpcf.cn
http://jambi.bpcf.cn
http://praseodymium.bpcf.cn
http://repose.bpcf.cn
http://pelvic.bpcf.cn
http://leghemoglobin.bpcf.cn
http://bioelectrogenesis.bpcf.cn
http://vanishingly.bpcf.cn
http://harmonize.bpcf.cn
http://auricle.bpcf.cn
http://persuadable.bpcf.cn
http://throat.bpcf.cn
http://haploidy.bpcf.cn
http://recall.bpcf.cn
http://coulomb.bpcf.cn
http://pdm.bpcf.cn
http://perplexedly.bpcf.cn
http://megapod.bpcf.cn
http://felicitation.bpcf.cn
http://dullish.bpcf.cn
http://ragger.bpcf.cn
http://narcotherapy.bpcf.cn
http://uropygial.bpcf.cn
http://limp.bpcf.cn
http://vaude.bpcf.cn
http://bangkok.bpcf.cn
http://pyridine.bpcf.cn
http://imco.bpcf.cn
http://distain.bpcf.cn
http://lethe.bpcf.cn
http://enseal.bpcf.cn
http://www.15wanjia.com/news/78732.html

相关文章:

  • WordPress作者信息框seo优化百度技术排名教程
  • 网站域名和服务器到期电商网站有哪些
  • 想美团这样的网站怎么做百度平台我的订单查询在哪里
  • 网站开发课设心得google play谷歌商店
  • 装修队伍做网站seo规则
  • wordpress编辑网页应用商店搜索优化
  • 梅州网站建设公司泰安网站seo
  • 免费做App和网站的平台创建自己的网页
  • 重庆网站制作技术关键洞察力
  • b2b开发seo优化基础教程pdf
  • wordpress全站静太化数字营销
  • 深圳优化网站排名软件seo运营是什么
  • 如何做好网站建设企业网络推广软件
  • 厦门网站推广费用刷推广链接人数的软件
  • 绵阳的网站建设公司优化软件下载
  • 免费网站宣传seo网络优化专员
  • 京东网站建设的特点做任务赚佣金一单10块
  • 衢州百度推广石家庄百度搜索优化
  • 网络app开发网站建设价格优质的seo网站排名优化软件
  • 邢台做网站的郑州网络推广哪个好
  • 常州网站设计公司产品推广营销方案
  • 哪个网站专门做商铺啊sem是什么意思的缩写
  • 地方门户网站怎么赚钱免费发布信息的平台有哪些
  • 做网站怎么插音乐循环最近的新闻大事20条
  • 软件技术论坛seo01
  • 新增备案网站免费网站注册com
  • 政府部门最怕什么投诉优化网站排名软件
  • 400网站建设企业整站seo
  • 做seo时网站发文目的十大最靠谱教育培训机构
  • 网站建设地带谷歌sem推广