mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 02:04:35 +00:00
Merge branch '0.9.2' into 0.9.3
This commit is contained in:
commit
1a787e1c8a
Binary file not shown.
@ -25,50 +25,45 @@
|
|||||||
# pragma message("GLM: GLM_GTX_vector_angle extension included")
|
# pragma message("GLM: GLM_GTX_vector_angle extension included")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace glm
|
namespace glm{
|
||||||
|
namespace gtx{
|
||||||
|
//! GLM_GTX_vector_angle extension: Compute angle between vectors
|
||||||
|
namespace vector_angle
|
||||||
{
|
{
|
||||||
namespace test{
|
using namespace quaternion;
|
||||||
void main_gtx_vector_angle();
|
using namespace epsilon;
|
||||||
}//namespace test
|
|
||||||
|
|
||||||
namespace gtx{
|
/// \addtogroup gtx_vector_angle
|
||||||
//! GLM_GTX_vector_angle extension: Compute angle between vectors
|
///@{
|
||||||
namespace vector_angle
|
|
||||||
{
|
|
||||||
using namespace quaternion;
|
|
||||||
using namespace epsilon;
|
|
||||||
|
|
||||||
/// \addtogroup gtx_vector_angle
|
//! Returns the absolute angle between two vectors
|
||||||
///@{
|
//! Parameters need to be normalized.
|
||||||
|
//! From GLM_GTX_vector_angle extension
|
||||||
|
template <typename vecType>
|
||||||
|
typename vecType::value_type angle(
|
||||||
|
vecType const & x,
|
||||||
|
vecType const & y);
|
||||||
|
|
||||||
//! Returns the absolute angle between x and y.
|
//! Returns the oriented angle between two 2d vectors
|
||||||
//! Parameters need to be normalized.
|
//! Parameters need to be normalized.
|
||||||
//! From GLM_GTX_vector_angle extension
|
//! From GLM_GTX_vector_angle extension.
|
||||||
template <typename vecType>
|
template <typename T>
|
||||||
typename vecType::value_type angle(
|
typename T orientedAngle(
|
||||||
vecType const & x,
|
detail::tvec2<T> const & x,
|
||||||
vecType const & y);
|
detail::tvec2<T> const & y);
|
||||||
|
|
||||||
//! Returns the oriented angle between x and y
|
//! Returns the oriented angle between two 3d vectors based from a reference axis.
|
||||||
//! Parameters need to be normalized.
|
//! Parameters need to be normalized.
|
||||||
//! From GLM_GTX_vector_angle extension.
|
//! From GLM_GTX_vector_angle extension.
|
||||||
template <typename vecType>
|
template <typename T>
|
||||||
typename vecType::value_type orientedAngle(
|
typename vecType<T> orientedAngle(
|
||||||
vecType const & x,
|
detail::tvec3<T> const & x,
|
||||||
vecType const & y);
|
detail::tvec3<T> const & y,
|
||||||
|
detail::tvec3<T> const & ref);
|
||||||
|
|
||||||
//! Returns the orientation of a two vector base from a normal.
|
///@}
|
||||||
//! Parameters need to be normalized.
|
}//namespace vector_angle
|
||||||
//! From GLM_GTX_vector_angle extension.
|
}//namespace gtx
|
||||||
template <template<typename> class vecType, typename T>
|
|
||||||
typename vecType<T> orientedAngleFromRef(
|
|
||||||
vecType<T> const & x,
|
|
||||||
vecType<T> const & y,
|
|
||||||
detail::tvec3<T> const & ref);
|
|
||||||
|
|
||||||
///@}
|
|
||||||
}//namespace vector_angle
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|
||||||
#include "vector_angle.inl"
|
#include "vector_angle.inl"
|
||||||
|
@ -29,62 +29,28 @@ GLM_FUNC_QUALIFIER valType orientedAngle
|
|||||||
detail::tvec2<valType> const & y
|
detail::tvec2<valType> const & y
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType Angle = acos(dot(x, y));
|
valType Angle = glm::degrees(acos(dot(x, y)));
|
||||||
valType c = cos(Angle);
|
detail::tvec2<valType> TransformedVector = glm::gtx::rotate_vector::rotate(x, Angle);
|
||||||
valType s = sin(Angle);
|
if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
|
||||||
detail::tvec2<valType> TransformedVector = detail::tvec2<valType>(c * y.x - s * y.y, s * y.x + c * y.y);
|
return Angle;
|
||||||
if(all(equalEpsilon(x, TransformedVector, valType(0.01))))
|
|
||||||
return -glm::degrees(Angle);
|
|
||||||
else
|
else
|
||||||
return glm::degrees(Angle);
|
return -Angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \todo epsilon is hard coded to 0.01
|
template <typename valType>
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER valType orientedAngle
|
GLM_FUNC_QUALIFIER valType orientedAngle
|
||||||
(
|
|
||||||
detail::tvec3<valType> const & x,
|
|
||||||
detail::tvec3<valType> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
valType Angle = degrees(acos(dot(x, y)));
|
|
||||||
detail::tvec3<valType> TransformedVector = glm::gtx::rotate_vector::rotate(y, Angle, glm::core::function::geometric::cross(x, y));
|
|
||||||
if(all(equalEpsilon(x, TransformedVector, valType(0.01))))
|
|
||||||
return -Angle;
|
|
||||||
else
|
|
||||||
return Angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER valType orientedAngleFromRef
|
|
||||||
(
|
|
||||||
detail::tvec2<valType> const & x,
|
|
||||||
detail::tvec2<valType> const & y,
|
|
||||||
detail::tvec3<valType> const & ref
|
|
||||||
)
|
|
||||||
{
|
|
||||||
valType Angle = glm::acos(glm::dot(x, y));
|
|
||||||
|
|
||||||
if(glm::dot(ref, detail::tvec3<valType>(glm::cross(x, y), valType(0))) < valType(0))
|
|
||||||
return -glm::degrees(Angle);
|
|
||||||
else
|
|
||||||
return glm::degrees(Angle);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER valType orientedAngleFromRef
|
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
detail::tvec3<valType> const & ref
|
detail::tvec3<valType> const & ref
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType Angle = glm::acos(glm::dot(x, y));
|
valType Angle = glm::degrees(glm::acos(glm::dot(x, y)));
|
||||||
|
|
||||||
if(glm::dot(ref, glm::cross(x, y)) < valType(0))
|
if(glm::dot(ref, glm::cross(x, y)) < valType(0))
|
||||||
return -glm::degrees(Angle);
|
return -Angle;
|
||||||
else
|
else
|
||||||
return glm::degrees(Angle);
|
return Angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace vector_angle
|
}//namespace vector_angle
|
||||||
|
@ -13,6 +13,14 @@ GLM is a header only library, there is nothing to build, just include it.
|
|||||||
More informations in GLM manual:
|
More informations in GLM manual:
|
||||||
http://glm.g-truc.net/glm-0.9.2.pdf
|
http://glm.g-truc.net/glm-0.9.2.pdf
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
GLM 0.9.2.1: 2010-05-20
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
- Automatically detect CUDA support
|
||||||
|
- Fixed errors and warnings in VC with C++ extensions disabled
|
||||||
|
- Fixed and tested GLM_GTX_vector_angle
|
||||||
|
- Fixed and tested GLM_GTX_rotate_vector
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.2.0: 2010-05-09
|
GLM 0.9.2.0: 2010-05-09
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -19,12 +19,12 @@ int test_vector_angle_calls()
|
|||||||
float AngleA = glm::angle(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
float AngleA = glm::angle(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||||
float AngleB = glm::orientedAngle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1)));
|
float AngleB = glm::orientedAngle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1)));
|
||||||
float AngleC = glm::orientedAngle(glm::vec2(0, 1), glm::normalize(glm::vec2(1, 1)));
|
float AngleC = glm::orientedAngle(glm::vec2(0, 1), glm::normalize(glm::vec2(1, 1)));
|
||||||
float AngleD = glm::orientedAngleFromRef(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0), glm::vec3(0, 0, 1));
|
float AngleD = glm::orientedAngle(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0), glm::vec3(0, 0, 1));
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_vector_angle_orientedAngle()
|
int test_orientedAngle_vec2()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
@ -32,11 +32,22 @@ int test_vector_angle_orientedAngle()
|
|||||||
Error += AngleA == 45.f ? 0 : 1;
|
Error += AngleA == 45.f ? 0 : 1;
|
||||||
float AngleB = glm::orientedAngle(glm::vec2(0, 1), glm::normalize(glm::vec2(1, 1)));
|
float AngleB = glm::orientedAngle(glm::vec2(0, 1), glm::normalize(glm::vec2(1, 1)));
|
||||||
Error += AngleB == -45.f ? 0 : 1;
|
Error += AngleB == -45.f ? 0 : 1;
|
||||||
|
float AngleC = glm::orientedAngle(glm::normalize(glm::vec2(1, 1)), glm::vec2(0, 1));
|
||||||
float AngleC = glm::orientedAngle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0)));
|
Error += AngleC == 45.f ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_orientedAngle_vec3()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
float AngleA = glm::orientedAngle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 0, 1));
|
||||||
|
Error += AngleA == 45.f ? 0 : 1;
|
||||||
|
float AngleB = glm::orientedAngle(glm::vec3(0, 1, 0), glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 0, 1));
|
||||||
|
Error += AngleB == -45.f ? 0 : 1;
|
||||||
|
float AngleC = glm::orientedAngle(glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 1, 0), glm::vec3(0, 0, 1));
|
||||||
Error += AngleC == 45.f ? 0 : 1;
|
Error += AngleC == 45.f ? 0 : 1;
|
||||||
float AngleD = glm::orientedAngle(glm::vec3(0, 1, 0), glm::normalize(glm::vec3(1, 1, 0)));
|
|
||||||
Error += AngleD == -45.f ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
@ -44,7 +55,8 @@ int test_vector_angle_orientedAngle()
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
Error += test_vector_angle_orientedAngle();
|
Error += test_orientedAngle_vec2();
|
||||||
|
Error += test_orientedAngle_vec3();
|
||||||
Error += test_vector_angle_calls();
|
Error += test_vector_angle_calls();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
|
Loading…
Reference in New Issue
Block a user