-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements a bunch of quaternion-specific functions
- Loading branch information
Showing
67 changed files
with
4,241 additions
and
105 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_dot : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_dot; | ||
|
||
KYOSU_DEFERS_CALLABLE(dot_); | ||
|
||
static KYOSU_FORCEINLINE auto deferred_call(auto | ||
, eve::ordered_value auto const& v0 | ||
, eve::ordered_value auto const& v1) noexcept | ||
{ | ||
return eve::dot(v0, v1); | ||
} | ||
|
||
KYOSU_FORCEINLINE auto operator()(auto const& target0, auto const& target1 ) const noexcept | ||
-> decltype(eve::tag_invoke(*this, target0, target1)) | ||
{ | ||
return eve::tag_invoke(*this, target0, target1); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_dot(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var dot | ||
//! @brief Computes elementwise the dot product of the coordinates of the corresponding element. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T0, kyosu::concepts::cayley_dickson T1 > constexpr auto dot(T0 z0, T1, z1) noexcept; | ||
//! template<eve::ordered_value T0, kyosu::concepts::cayley_dickson T1> > constexpr auto dot(T0 z0, T1, z1) noexcept; | ||
//! template<kyosu::concepts::cayley_dickson T0, eve::ordered_value T1 > constexpr auto dot(T0 z0, T1, z1) noexcept; | ||
//! template<eve::ordered_value T0, ordered_value T1> > constexpr auto dot(T0 z0, T1, z1) noexcept; | ||
///! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z0, z1` : Value to process. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! Returns the dot product of z0 and z1. If z0 and z1 are floating point this is equivalent to z0*z1. | ||
//! | ||
//! `dot(z0, z0)` is always semantically equivalent to `sqr_abs(z0)`. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/dot.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_dot dot = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//================================================================================================== | ||
/* | ||
KYOSU - Expressive Vector Engine | ||
Copyright : KYOSU Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
#include <kyosu/types/impl/quaternion/axis.hpp> | ||
#include <kyosu/functions/to_quaternion.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_from_angle_axis : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_from_angle_axis; | ||
|
||
KYOSU_DEFERS_CALLABLE(from_angle_axis_); | ||
|
||
template<eve::ordered_value V, eve::ordered_value U> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto | ||
, V const & angle | ||
, std::span<U, 3> axis) noexcept | ||
{ | ||
auto q = to_quaternion(U(0), axis[0], axis[1], axis[2]); | ||
auto [s, c] = eve::sincos(angle*eve::half(eve::as(angle))); | ||
return c+s*q; | ||
} | ||
|
||
template<typename T0, typename T1> | ||
KYOSU_FORCEINLINE auto operator()(T0 const& target0, | ||
T1 const& target1 | ||
) const noexcept | ||
-> decltype(eve::tag_invoke(*this, target0, target1)) | ||
{ | ||
return eve::tag_invoke(*this, target0, target1); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_from_angle_axis(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//================================================================================================ | ||
//! @addtogroup quaternion | ||
//! @{ | ||
//! @var from_angle_axis | ||
//! | ||
//! @brief Callable object computing a quaternion from its angle_axis representation. | ||
//! | ||
//! This function build an unitary quaternion from an angle value and a 3 dimensionnal axis vector | ||
//! | ||
//! **Defined in header** | ||
//! | ||
//! @code | ||
//! #include kyosu/module/quaternion.hpp>` | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! auto from_angle_axis(auto angle, auto axis, auto norming = normalize) const noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `angle` : rotation angle in radian | ||
//! * `axis`` : rotation axis given by an std::span of dimension 3. | ||
//! * normalize : can be assume_normalized or normalize in the second case axis is normalized. | ||
//! if axis is already normalized use assume_normalized. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! the quaternion value representing the rotation. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/quaternion/regular/conversions.cpp} | ||
//! @} | ||
//================================================================================================ | ||
inline constexpr tags::callable_from_angle_axis from_angle_axis = {}; | ||
} |
Oops, something went wrong.