renamed values
This commit is contained in:
@@ -182,16 +182,16 @@ namespace hgl
|
||||
/**
|
||||
* 计算一个方向旋转成另一个方向的变换矩阵
|
||||
*/
|
||||
const Matrix4f GetRotateMatrix(const Vector3f &world_position,const Vector3f &cur_direction,const Vector3f &new_direction)
|
||||
const Matrix4f GetRotateMatrix(const Vector3f &world_position,const Vector3f &old_direction,const Vector3f &new_direction)
|
||||
{
|
||||
Vector3f axis=glm::cross(cur_direction,new_direction);
|
||||
Vector3f axis=glm::cross(old_direction,new_direction);
|
||||
|
||||
if(glm::length2(axis)<0.0001)
|
||||
return Matrix4f(1.0f);
|
||||
|
||||
axis=glm::normalize(axis);
|
||||
|
||||
float angle=acos(glm::dot(cur_direction,new_direction));
|
||||
float angle=acos(glm::dot(old_direction,new_direction));
|
||||
|
||||
return glm::rotate(Matrix4f(1.0f),angle,axis);
|
||||
}
|
||||
@@ -199,16 +199,16 @@ namespace hgl
|
||||
/**
|
||||
* 计算一个方向旋转成另一个方向的四元数
|
||||
*/
|
||||
const Quatf GetRotateQuat(const Vector3f &world_position,const Vector3f &cur_direction,const Vector3f &new_direction)
|
||||
const Quatf GetRotateQuat(const Vector3f &world_position,const Vector3f &old_direction,const Vector3f &new_direction)
|
||||
{
|
||||
Vector3f axis=glm::cross(cur_direction,new_direction);
|
||||
Vector3f axis=glm::cross(old_direction,new_direction);
|
||||
|
||||
if(glm::length2(axis)<0.0001)
|
||||
return Quatf(1.0f,0.0f,0.0f,0.0f);
|
||||
|
||||
axis=glm::normalize(axis);
|
||||
|
||||
float angle=acos(glm::dot(cur_direction,new_direction));
|
||||
float angle=acos(glm::dot(old_direction,new_direction));
|
||||
|
||||
return glm::angleAxis(angle,axis);
|
||||
}
|
||||
|
Reference in New Issue
Block a user