Skip to content

Commit

Permalink
Added long double versions of various maths classes/functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Nov 20, 2024
1 parent d7e8146 commit 2e42b7a
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/vsg/maths/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ namespace vsg

using box = t_box<float>; /// float box class
using dbox = t_box<double>; /// double box class
using ldbox = t_box<long double>; /// double box class

VSG_type_name(vsg::box);
VSG_type_name(vsg::dbox);
VSG_type_name(vsg::ldbox);

template<typename T>
constexpr bool operator==(const t_box<T>& lhs, const t_box<T>& rhs)
Expand Down
2 changes: 2 additions & 0 deletions include/vsg/maths/mat4.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ namespace vsg

using mat4 = t_mat4<float>; /// float 4x4 matrix
using dmat4 = t_mat4<double>; /// double 4x4 matrix
using ldmat4 = t_mat4<long double>; /// long double 4x4 matrix

VSG_type_name(vsg::mat4);
VSG_type_name(vsg::dmat4);
VSG_type_name(vsg::ldmat4);

template<typename T>
bool operator==(const t_mat4<T>& lhs, const t_mat4<T>& rhs)
Expand Down
1 change: 1 addition & 0 deletions include/vsg/maths/plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace vsg

using plane = t_plane<float>;
using dplane = t_plane<double>;
using ldplane = t_plane<long double>;

VSG_type_name(vsg::plane);
VSG_type_name(vsg::dplane);
Expand Down
2 changes: 2 additions & 0 deletions include/vsg/maths/quat.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ namespace vsg

using quat = t_quat<float>; /// float quaternion
using dquat = t_quat<double>; /// double quaternion
using ldquat = t_quat<long double>; /// long double quaternion

VSG_type_name(vsg::quat);
VSG_type_name(vsg::dquat);
VSG_type_name(vsg::ldquat);

template<typename T>
constexpr bool operator==(const t_quat<T>& lhs, const t_quat<T>& rhs)
Expand Down
2 changes: 2 additions & 0 deletions include/vsg/maths/sphere.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ namespace vsg

using sphere = t_sphere<float>; /// float sphere class
using dsphere = t_sphere<double>; /// double sphere class
using ldsphere = t_sphere<long double>; /// long double sphere class

VSG_type_name(vsg::sphere);
VSG_type_name(vsg::dsphere);
VSG_type_name(vsg::ldsphere);

template<typename T>
constexpr bool operator==(const t_sphere<T>& lhs, const t_sphere<T>& rhs)
Expand Down
5 changes: 5 additions & 0 deletions include/vsg/maths/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ namespace vsg
/// assumes matrix has no skew or perspective components
extern VSG_DECLSPEC bool decompose(const dmat4& m, dvec3& translation, dquat& rotation, dvec3& scale);

/// decompose long double matrix into translation, rotation and scale components.
/// maps to TRS form: vsg::translate(translation) * vsg::rotate(rotation) * vsg::scale(scale);
/// assumes matrix has no skew or perspective components
extern VSG_DECLSPEC bool decompose(const ldmat4& m, ldvec3& translation, ldquat& rotation, ldvec3& scale);

/// compute the bounding sphere that encloses a frustum defined by specified float ModelViewMatrixProjection
extern VSG_DECLSPEC sphere computeFrustumBound(const mat4& m);

Expand Down
1 change: 1 addition & 0 deletions include/vsg/maths/vec2.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace vsg

using vec2 = t_vec2<float>; // float 2D vector
using dvec2 = t_vec2<double>; // double 2D vector
using ldvec2 = t_vec2<long double>; // long double 2D vector
using bvec2 = t_vec2<int8_t>; // signed 8 bit integer 2D vector
using svec2 = t_vec2<int16_t>; // signed 16 bit integer 2D vector
using ivec2 = t_vec2<int32_t>; // signed 32 bit integer 2D vector
Expand Down
2 changes: 2 additions & 0 deletions include/vsg/maths/vec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ namespace vsg

using vec3 = t_vec3<float>; // float 3D vector
using dvec3 = t_vec3<double>; // double 3D vector
using ldvec3 = t_vec3<long double>; // long double 3D vector
using bvec3 = t_vec3<int8_t>; // signed 8 bit integer 3D vector
using svec3 = t_vec3<int16_t>; // signed 16 bit integer 3D vector
using ivec3 = t_vec3<int32_t>; // signed 32 bit integer 3D vector
Expand All @@ -155,6 +156,7 @@ namespace vsg

VSG_type_name(vsg::vec3);
VSG_type_name(vsg::dvec3);
VSG_type_name(vsg::ldvec3);
VSG_type_name(vsg::bvec3);
VSG_type_name(vsg::svec3);
VSG_type_name(vsg::ivec3);
Expand Down
2 changes: 2 additions & 0 deletions include/vsg/maths/vec4.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ namespace vsg

using vec4 = t_vec4<float>; // float 4D vector
using dvec4 = t_vec4<double>; // double 4D vector
using ldvec4 = t_vec4<long double>; // long double 4D vector
using bvec4 = t_vec4<int8_t>; // signed 8 bit integer 4D vector
using svec4 = t_vec4<int16_t>; // signed 16 bit integer 4D vector
using ivec4 = t_vec4<int32_t>; // signed 32 bit integer 4D vector
Expand All @@ -185,6 +186,7 @@ namespace vsg

VSG_type_name(vsg::vec4);
VSG_type_name(vsg::dvec4);
VSG_type_name(vsg::ldvec4);
VSG_type_name(vsg::bvec4);
VSG_type_name(vsg::svec4);
VSG_type_name(vsg::ivec4);
Expand Down
5 changes: 5 additions & 0 deletions src/vsg/maths/maths_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ bool vsg::decompose(const dmat4& m, dvec3& translation, dquat& rotation, dvec3&
return t_decompose<double>(m, translation, rotation, scale);
}

bool vsg::decompose(const ldmat4& m, ldvec3& translation, ldquat& rotation, ldvec3& scale)
{
return t_decompose<long double>(m, translation, rotation, scale);
}

///////////////////////////////////////////////////////////////////////////////////////////////////
//
// computeFrustumBound
Expand Down

0 comments on commit 2e42b7a

Please sign in to comment.