最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

unity 四元数旋转各元素值的计算方法

IT培训 admin 5浏览 0评论

unity 四元数旋转各元素值的计算方法

// 旋转轴
Vector3 axis = Vector3.up;
// 旋转弧度
float rad = 50f * Mathf.Deg2Rad;Quaternion quaternion = new Quaternion();
quaternion.x = Mathf.Sin(rad / 2f) * axis.x;
quaternion.y = Mathf.Sin(rad / 2f) * axis.y;
quaternion.z = Mathf.Sin(rad / 2f) * axis.z;
quaternion.w = Mathf.Cos(rad / 2f);transform.rotation = quaternion;
// 相当于
//transform.rotation = Quaternion.Euler(0f, 50f, 0f);

unity 四元数旋转各元素值的计算方法

// 旋转轴
Vector3 axis = Vector3.up;
// 旋转弧度
float rad = 50f * Mathf.Deg2Rad;Quaternion quaternion = new Quaternion();
quaternion.x = Mathf.Sin(rad / 2f) * axis.x;
quaternion.y = Mathf.Sin(rad / 2f) * axis.y;
quaternion.z = Mathf.Sin(rad / 2f) * axis.z;
quaternion.w = Mathf.Cos(rad / 2f);transform.rotation = quaternion;
// 相当于
//transform.rotation = Quaternion.Euler(0f, 50f, 0f);
11136
发布评论

评论列表 (0)

  1. 暂无评论