renamed values

This commit is contained in:
hyzboy 2024-08-02 22:39:21 +08:00
parent 866f69034b
commit 0dd89d78ab
3 changed files with 10 additions and 15 deletions

View File

@ -215,8 +215,8 @@ namespace hgl
return root*child; return root*child;
} }
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);
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);
/** /**
* *

View File

@ -414,14 +414,9 @@ namespace hgl
&&IsNearlyEqual(a.z,b.z); &&IsNearlyEqual(a.z,b.z);
} }
inline const Vector3f LerpDirection(const Vector3f &center,const Vector3f &from_direction,const Vector3f &to_direction,const float alpha) inline const Vector3f LerpDirection(const Vector3f &old_direction,const Vector3f &new_direction,const float alpha)
{ {
return glm::normalize(center + (from_direction - center) * alpha + (to_direction - center) * alpha); return glm::normalize(old_direction*(1.0f-alpha)+new_direction*alpha);
}
inline const Vector3f SLerpDirection(const Vector3f &center,const Vector3f &from,const Vector3f &to,const float alpha)
{
return glm::normalize(glm::slerp(from - center, to - center, alpha) + center);
} }
}//namespace hgl }//namespace hgl
#endif//HGL_ALGORITHM_MATH_VECTOR_INCLUDE #endif//HGL_ALGORITHM_MATH_VECTOR_INCLUDE

View File

@ -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) if(glm::length2(axis)<0.0001)
return Matrix4f(1.0f); return Matrix4f(1.0f);
axis=glm::normalize(axis); 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); 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) if(glm::length2(axis)<0.0001)
return Quatf(1.0f,0.0f,0.0f,0.0f); return Quatf(1.0f,0.0f,0.0f,0.0f);
axis=glm::normalize(axis); 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); return glm::angleAxis(angle,axis);
} }