Added vec2 cross #621
This commit is contained in:
parent
96adec5f5e
commit
40398d67cd
40
glm/gtx/exterior_product.hpp
Normal file
40
glm/gtx/exterior_product.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/// @ref gtx_exterior_product
|
||||
/// @file glm/gtx/exterior_product.hpp
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtx_exterior_product (dependence)
|
||||
///
|
||||
/// @defgroup gtx_exterior_product GLM_GTX_exterior_product
|
||||
/// @ingroup gtx
|
||||
///
|
||||
/// @brief Allow to perform bit operations on integer values
|
||||
///
|
||||
/// <glm/gtc/bitfield.hpp> need to be included to use these functionalities.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
|
||||
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTX_exterior_product extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtx_exterior_product
|
||||
/// @{
|
||||
|
||||
/// Returns the cross product of x and y.
|
||||
///
|
||||
/// @tparam valType Floating-point scalar types.
|
||||
///
|
||||
/// @see <a href="https://en.wikipedia.org/wiki/Exterior_algebra#Cross_and_triple_products">Exterior product</a>
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_DECL T cross(vec<2, T, P> const& v, vec<2, T, P> const& u);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
#include "exterior_product.inl"
|
27
glm/gtx/exterior_product.inl
Normal file
27
glm/gtx/exterior_product.inl
Normal file
@ -0,0 +1,27 @@
|
||||
/// @ref core
|
||||
/// @file glm/detail/func_geometric.inl
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace glm {
|
||||
namespace detail
|
||||
{
|
||||
template<typename T, precision P, bool Aligned>
|
||||
struct compute_cross_vec2
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static T call(vec<2, T, P> const& v, vec<2, T, P> const& u)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cross' accepts only floating-point inputs");
|
||||
|
||||
return v.x * u.y - u.x * v.y;
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T cross(vec<2, T, P> const & x, vec<2, T, P> const & y)
|
||||
{
|
||||
return detail::compute_cross_vec2<T, P, detail::is_aligned<P>::value>::call(x, y);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -56,6 +56,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
||||
- Added RGBM encoding in GTC_packing #420
|
||||
- Added GTX_color_encoding extension
|
||||
- Added GTX_vec_swizzle, faster compile time swizzling then swizzle operator #558
|
||||
- Added GTX_exterior_product with a vec2 cross implementation #621
|
||||
- Added [GLM_ENABLE_EXPERIMENTAL](manual.md#section7_4) to enable experimental features.
|
||||
|
||||
#### Improvements:
|
||||
|
@ -9,6 +9,7 @@ glmCreateTestGTC(gtx_component_wise)
|
||||
glmCreateTestGTC(gtx_euler_angle)
|
||||
glmCreateTestGTC(gtx_extend)
|
||||
glmCreateTestGTC(gtx_extended_min_max)
|
||||
glmCreateTestGTC(gtx_exterior_product)
|
||||
glmCreateTestGTC(gtx_fast_exponential)
|
||||
glmCreateTestGTC(gtx_fast_square_root)
|
||||
glmCreateTestGTC(gtx_fast_trigonometry)
|
||||
|
14
test/gtx/gtx_exterior_product.cpp
Normal file
14
test/gtx/gtx_exterior_product.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <glm/gtx/exterior_product.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float const f = glm::cross(glm::vec2(1.0f, 1.0f), glm::vec2(1.0f, 1.0f));
|
||||
Error += glm::epsilonEqual(f, 0.0f, 0.001f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user