float angle = 40;
Vector3 v = rotatePoint.transform.position;
Debug.Log("旋转向量 " + v + "__自身 " + cube.transform.rotation);
v.Normalize();
Debug.Log(v);
float f = angle * Mathf.Deg2Rad / 2;
float sinHalfAngle = Mathf.Sin(f);
float cosHalfAngle = Mathf.Cos(f);
Quaternion q = new Quaternion(sinHalfAngle * v.x, sinHalfAngle * v.y, sinHalfAngle * v.z, cosHalfAngle);
Debug.Log("旋转的 ;" + q + "__" + q.eulerAngles);
Quaternion vv = cube.transform.rotation * q;
Debug.Log("预估欧拉1 :" + vv + vv.eulerAngles);
cube.transform.Rotate(v, angle);
Debug.Log("实际欧拉2 :" + cube.transform.rotation + "__" + cube.transform.rotation.eulerAngles);
Debug.Log(rotatePoint.transform.position);
参考网址:
Unity--四元数(Quaternion)和旋转_阿成_的博客-CSDN博客
Unity-四元数_unity 四元数相乘_我和BUG只能活一个的博客-CSDN博客