mirror of
https://github.com/g-truc/glm.git
synced 2024-11-23 09:14:34 +00:00
Added vec3 slerp #237
This commit is contained in:
parent
4649717f45
commit
0d42f4a320
@ -51,6 +51,19 @@ namespace glm
|
|||||||
/// @addtogroup gtx_rotate_vector
|
/// @addtogroup gtx_rotate_vector
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
/// Returns the length of the quaternion.
|
||||||
|
///
|
||||||
|
/// @param x A first vector
|
||||||
|
/// @param y A second vector
|
||||||
|
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
|
||||||
|
///
|
||||||
|
/// @see gtc_quaternion
|
||||||
|
template <typename T, precision P>
|
||||||
|
GLM_FUNC_DECL detail::tvec3<T, P> slerp(
|
||||||
|
detail::tvec3<T, P> const & x,
|
||||||
|
detail::tvec3<T, P> const & y,
|
||||||
|
T const & a);
|
||||||
|
|
||||||
//! Rotate a two dimensional vector.
|
//! Rotate a two dimensional vector.
|
||||||
//! From GLM_GTX_rotate_vector extension.
|
//! From GLM_GTX_rotate_vector extension.
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
|
@ -9,6 +9,28 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
|
template <typename T, precision P>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec3<T, P> slerp
|
||||||
|
(
|
||||||
|
detail::tvec3<T, P> const & x,
|
||||||
|
detail::tvec3<T, P> const & y,
|
||||||
|
T const & a
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// get cosine of angle between vectors (-1 -> 1)
|
||||||
|
T CosAlpha = dot(x, y);
|
||||||
|
// get angle (0 -> pi)
|
||||||
|
T Alpha = acos(CosAlpha);
|
||||||
|
// get sine of angle between vectors (0 -> 1)
|
||||||
|
T SinAlpha = sin(Alpha);
|
||||||
|
// this breaks down when SinAlpha = 0, i.e. Alpha = 0 or pi
|
||||||
|
T t1 = sin((static_cast<T>(1) - a) * Alpha) / SinAlpha;
|
||||||
|
T t2 = sin(a * Alpha) / sinAlpha;
|
||||||
|
|
||||||
|
// interpolate src vectors
|
||||||
|
return x * t1 + y * t2;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T, P> rotate
|
GLM_FUNC_QUALIFIER detail::tvec2<T, P> rotate
|
||||||
(
|
(
|
||||||
|
@ -48,6 +48,7 @@ GLM 0.9.6.0: 2014-XX-XX
|
|||||||
- Added *vec1 support to *vec2 types
|
- Added *vec1 support to *vec2 types
|
||||||
- Limited extended integer type redifinition (#233)
|
- Limited extended integer type redifinition (#233)
|
||||||
- Improved linearRand: support precision and integers (#230)
|
- Improved linearRand: support precision and integers (#230)
|
||||||
|
- Added vec3 slerp (#237)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.5.5: 2014-XX-XX
|
GLM 0.9.5.5: 2014-XX-XX
|
||||||
|
Loading…
Reference in New Issue
Block a user