From 4014c119cbe433c3421566c337225e5afd51028c Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 11 Nov 2020 22:37:16 +0800 Subject: [PATCH] add PolarToVector3f/4f functions. --- inc/hgl/math/Vector.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/inc/hgl/math/Vector.h b/inc/hgl/math/Vector.h index 04a1ce9..c06379a 100644 --- a/inc/hgl/math/Vector.h +++ b/inc/hgl/math/Vector.h @@ -353,5 +353,15 @@ namespace hgl operator const Vector4f()const{return Vector4f(x,y,z,w);} }; + + inline const Vector3f PolarToVector3f(float yaw,float pitch) + { + return Vector3f(sinf(yaw) * cosf(pitch), sinf(pitch), cosf(yaw) * cosf(pitch)); + } + + inline const Vector4f PolarToVector4f(float yaw,float pitch) + { + return Vector4f(sinf(yaw) * cosf(pitch), sinf(pitch), cosf(yaw) * cosf(pitch), 0); + } }//namespace hgl #endif//HGL_ALGORITHM_MATH_VECTOR_INCLUDE