Skip to content

Commit 2e42b7a

Browse files
committed
Added long double versions of various maths classes/functions.
1 parent d7e8146 commit 2e42b7a

File tree

10 files changed

+24
-0
lines changed

10 files changed

+24
-0
lines changed

include/vsg/maths/box.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ namespace vsg
9090

9191
using box = t_box<float>; /// float box class
9292
using dbox = t_box<double>; /// double box class
93+
using ldbox = t_box<long double>; /// double box class
9394

9495
VSG_type_name(vsg::box);
9596
VSG_type_name(vsg::dbox);
97+
VSG_type_name(vsg::ldbox);
9698

9799
template<typename T>
98100
constexpr bool operator==(const t_box<T>& lhs, const t_box<T>& rhs)

include/vsg/maths/mat4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ namespace vsg
121121

122122
using mat4 = t_mat4<float>; /// float 4x4 matrix
123123
using dmat4 = t_mat4<double>; /// double 4x4 matrix
124+
using ldmat4 = t_mat4<long double>; /// long double 4x4 matrix
124125

125126
VSG_type_name(vsg::mat4);
126127
VSG_type_name(vsg::dmat4);
128+
VSG_type_name(vsg::ldmat4);
127129

128130
template<typename T>
129131
bool operator==(const t_mat4<T>& lhs, const t_mat4<T>& rhs)

include/vsg/maths/plane.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ namespace vsg
110110

111111
using plane = t_plane<float>;
112112
using dplane = t_plane<double>;
113+
using ldplane = t_plane<long double>;
113114

114115
VSG_type_name(vsg::plane);
115116
VSG_type_name(vsg::dplane);

include/vsg/maths/quat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ namespace vsg
147147

148148
using quat = t_quat<float>; /// float quaternion
149149
using dquat = t_quat<double>; /// double quaternion
150+
using ldquat = t_quat<long double>; /// long double quaternion
150151

151152
VSG_type_name(vsg::quat);
152153
VSG_type_name(vsg::dquat);
154+
VSG_type_name(vsg::ldquat);
153155

154156
template<typename T>
155157
constexpr bool operator==(const t_quat<T>& lhs, const t_quat<T>& rhs)

include/vsg/maths/sphere.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ namespace vsg
122122

123123
using sphere = t_sphere<float>; /// float sphere class
124124
using dsphere = t_sphere<double>; /// double sphere class
125+
using ldsphere = t_sphere<long double>; /// long double sphere class
125126

126127
VSG_type_name(vsg::sphere);
127128
VSG_type_name(vsg::dsphere);
129+
VSG_type_name(vsg::ldsphere);
128130

129131
template<typename T>
130132
constexpr bool operator==(const t_sphere<T>& lhs, const t_sphere<T>& rhs)

include/vsg/maths/transform.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ namespace vsg
248248
/// assumes matrix has no skew or perspective components
249249
extern VSG_DECLSPEC bool decompose(const dmat4& m, dvec3& translation, dquat& rotation, dvec3& scale);
250250

251+
/// decompose long double matrix into translation, rotation and scale components.
252+
/// maps to TRS form: vsg::translate(translation) * vsg::rotate(rotation) * vsg::scale(scale);
253+
/// assumes matrix has no skew or perspective components
254+
extern VSG_DECLSPEC bool decompose(const ldmat4& m, ldvec3& translation, ldquat& rotation, ldvec3& scale);
255+
251256
/// compute the bounding sphere that encloses a frustum defined by specified float ModelViewMatrixProjection
252257
extern VSG_DECLSPEC sphere computeFrustumBound(const mat4& m);
253258

include/vsg/maths/vec2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ namespace vsg
138138

139139
using vec2 = t_vec2<float>; // float 2D vector
140140
using dvec2 = t_vec2<double>; // double 2D vector
141+
using ldvec2 = t_vec2<long double>; // long double 2D vector
141142
using bvec2 = t_vec2<int8_t>; // signed 8 bit integer 2D vector
142143
using svec2 = t_vec2<int16_t>; // signed 16 bit integer 2D vector
143144
using ivec2 = t_vec2<int32_t>; // signed 32 bit integer 2D vector

include/vsg/maths/vec3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ namespace vsg
146146

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

156157
VSG_type_name(vsg::vec3);
157158
VSG_type_name(vsg::dvec3);
159+
VSG_type_name(vsg::ldvec3);
158160
VSG_type_name(vsg::bvec3);
159161
VSG_type_name(vsg::svec3);
160162
VSG_type_name(vsg::ivec3);

include/vsg/maths/vec4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ namespace vsg
176176

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

186187
VSG_type_name(vsg::vec4);
187188
VSG_type_name(vsg::dvec4);
189+
VSG_type_name(vsg::ldvec4);
188190
VSG_type_name(vsg::bvec4);
189191
VSG_type_name(vsg::svec4);
190192
VSG_type_name(vsg::ivec4);

src/vsg/maths/maths_transform.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ bool vsg::decompose(const dmat4& m, dvec3& translation, dquat& rotation, dvec3&
297297
return t_decompose<double>(m, translation, rotation, scale);
298298
}
299299

300+
bool vsg::decompose(const ldmat4& m, ldvec3& translation, ldquat& rotation, ldvec3& scale)
301+
{
302+
return t_decompose<long double>(m, translation, rotation, scale);
303+
}
304+
300305
///////////////////////////////////////////////////////////////////////////////////////////////////
301306
//
302307
// computeFrustumBound

0 commit comments

Comments
 (0)