Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
waLBerla
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Schruff
waLBerla
Commits
aa5cedc8
Commit
aa5cedc8
authored
7 years ago
by
Michael Kuron
Browse files
Options
Downloads
Patches
Plain Diff
Remove invalid quaternion normalization
parent
d16256a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/math/Quaternion.h
+4
-63
4 additions, 63 deletions
src/core/math/Quaternion.h
with
4 additions
and
63 deletions
src/core/math/Quaternion.h
+
4
−
63
View file @
aa5cedc8
...
@@ -152,9 +152,6 @@ public:
...
@@ -152,9 +152,6 @@ public:
//@{
//@{
inline
Quaternion
&
set
(
Type
r
,
Type
i
,
Type
j
,
Type
k
);
inline
Quaternion
&
set
(
Type
r
,
Type
i
,
Type
j
,
Type
k
);
inline
void
reset
();
inline
void
reset
();
inline
Type
length
()
const
;
inline
Quaternion
&
normalize
();
inline
const
Quaternion
getNormalized
()
const
;
inline
Quaternion
&
invert
();
inline
Quaternion
&
invert
();
inline
const
Quaternion
getInverse
()
const
;
inline
const
Quaternion
getInverse
()
const
;
inline
const
Matrix3
<
Type
>
toRotationMatrix
()
const
;
inline
const
Matrix3
<
Type
>
toRotationMatrix
()
const
;
...
@@ -249,7 +246,7 @@ template< typename Type > // Data type of the quaternion
...
@@ -249,7 +246,7 @@ template< typename Type > // Data type of the quaternion
inline
Quaternion
<
Type
>::
Quaternion
(
Type
r
,
Type
i
,
Type
j
,
Type
k
)
inline
Quaternion
<
Type
>::
Quaternion
(
Type
r
,
Type
i
,
Type
j
,
Type
k
)
{
{
v_
[
0
]
=
r
;
v_
[
1
]
=
i
;
v_
[
2
]
=
j
;
v_
[
3
]
=
k
;
v_
[
0
]
=
r
;
v_
[
1
]
=
i
;
v_
[
2
]
=
j
;
v_
[
3
]
=
k
;
WALBERLA_
ASSERT
_FLOAT_EQUAL
(
r
*
r
+
i
*
i
+
j
*
j
+
k
*
k
,
Type
(
1
),
"Invalid quaternion parameters"
);
WALBERLA_
CHECK
_FLOAT_EQUAL
(
r
*
r
+
i
*
i
+
j
*
j
+
k
*
k
,
Type
(
1
),
"Invalid quaternion parameters"
);
}
}
//*************************************************************************************************
//*************************************************************************************************
...
@@ -279,7 +276,7 @@ inline Quaternion<Type>::Quaternion( Vector3<Axis> axis, Type angle )
...
@@ -279,7 +276,7 @@ inline Quaternion<Type>::Quaternion( Vector3<Axis> axis, Type angle )
return
;
return
;
}
}
WALBERLA_
ASSERT
(
axis
.
sqrLength
()
>
Axis
(
0
),
"Invalid rotation axis"
);
WALBERLA_
CHECK
(
axis
.
sqrLength
()
>
Axis
(
0
),
"Invalid rotation axis"
);
const
Type
sina
(
std
::
sin
(
angle
*
Type
(
0.5
)
)
);
const
Type
sina
(
std
::
sin
(
angle
*
Type
(
0.5
)
)
);
const
Type
cosa
(
std
::
cos
(
angle
*
Type
(
0.5
)
)
);
const
Type
cosa
(
std
::
cos
(
angle
*
Type
(
0.5
)
)
);
...
@@ -432,7 +429,7 @@ inline Quaternion<Type>& Quaternion<Type>::operator=( const Quaternion<Other>& r
...
@@ -432,7 +429,7 @@ inline Quaternion<Type>& Quaternion<Type>::operator=( const Quaternion<Other>& r
* \param index Access index. The index has to be in the range \f$[0..3]\f$.
* \param index Access index. The index has to be in the range \f$[0..3]\f$.
* \return Copy of the accessed element.
* \return Copy of the accessed element.
*
*
*
In case pe_USER_ASSERT() is activ
e, this operator performs an index check.
*
When compiled in Debug mod
e, this operator performs an index check.
*/
*/
template
<
typename
Type
>
// Data type of the quaternion
template
<
typename
Type
>
// Data type of the quaternion
inline
Type
Quaternion
<
Type
>::
operator
[](
size_t
index
)
const
inline
Type
Quaternion
<
Type
>::
operator
[](
size_t
index
)
const
...
@@ -462,7 +459,7 @@ inline Type Quaternion<Type>::operator[]( size_t index ) const
...
@@ -462,7 +459,7 @@ inline Type Quaternion<Type>::operator[]( size_t index ) const
template
<
typename
Type
>
// Data type of the quaternion
template
<
typename
Type
>
// Data type of the quaternion
inline
Quaternion
<
Type
>&
Quaternion
<
Type
>::
set
(
Type
r
,
Type
i
,
Type
j
,
Type
k
)
inline
Quaternion
<
Type
>&
Quaternion
<
Type
>::
set
(
Type
r
,
Type
i
,
Type
j
,
Type
k
)
{
{
WALBERLA_
ASSERT
_FLOAT_EQUAL
(
std
::
fabs
(
r
*
r
+
i
*
i
+
j
*
j
+
k
*
k
),
Type
(
1
),
"Invalid quaternion parameters"
);
WALBERLA_
CHECK
_FLOAT_EQUAL
(
std
::
fabs
(
r
*
r
+
i
*
i
+
j
*
j
+
k
*
k
),
Type
(
1
),
"Invalid quaternion parameters"
);
v_
[
0
]
=
r
;
v_
[
0
]
=
r
;
v_
[
1
]
=
i
;
v_
[
1
]
=
i
;
v_
[
2
]
=
j
;
v_
[
2
]
=
j
;
...
@@ -493,62 +490,6 @@ inline void Quaternion<Type>::reset()
...
@@ -493,62 +490,6 @@ inline void Quaternion<Type>::reset()
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Calculation of the quaternion length \f$|\hat{q}|\f$.
*
* \return The length of the quaternion.
*/
template
<
typename
Type
>
// Data type of the quaternion
inline
Type
Quaternion
<
Type
>::
length
()
const
{
// Although the length of the quaternion should always be exactly one, the function
// calculates the actual length to enable length checks.
return
std
::
sqrt
(
v_
[
0
]
*
v_
[
0
]
+
v_
[
1
]
*
v_
[
1
]
+
v_
[
2
]
*
v_
[
2
]
+
v_
[
3
]
*
v_
[
3
]
);
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Normalization of the quaternion (\f$|\hat{q}|=1\f$).
*
* \return Reference to the quaternion.
*/
template
<
typename
Type
>
// Data type of the quaternion
inline
Quaternion
<
Type
>&
Quaternion
<
Type
>::
normalize
()
{
const
Type
len
(
std
::
sqrt
(
v_
[
0
]
*
v_
[
0
]
+
v_
[
1
]
*
v_
[
1
]
+
v_
[
2
]
*
v_
[
2
]
+
v_
[
3
]
*
v_
[
3
]
)
);
WALBERLA_ASSERT_NOT_IDENTICAL
(
len
,
Type
(
0
)
);
const
Type
ilen
(
Type
(
1
)
/
len
);
v_
[
0
]
*=
ilen
;
v_
[
1
]
*=
ilen
;
v_
[
2
]
*=
ilen
;
v_
[
3
]
*=
ilen
;
return
*
this
;
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Calculation of the normalized quaternion (\f$|\hat{q}|=1\f$).
*
* \return The normalized quaternion.
*/
template
<
typename
Type
>
// Data type of the quaternion
inline
const
Quaternion
<
Type
>
Quaternion
<
Type
>::
getNormalized
()
const
{
const
Type
len
(
std
::
sqrt
(
v_
[
0
]
*
v_
[
0
]
+
v_
[
1
]
*
v_
[
1
]
+
v_
[
2
]
*
v_
[
2
]
+
v_
[
3
]
*
v_
[
3
]
)
);
WALBERLA_ASSERT_NOT_IDENTICAL
(
len
,
Type
(
0
)
);
const
Type
ilen
(
Type
(
1
)
/
len
);
return
Quaternion
(
ilen
*
v_
[
0
],
ilen
*
v_
[
1
],
ilen
*
v_
[
2
],
ilen
*
v_
[
3
]
);
}
//*************************************************************************************************
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Inversion of the quaternion (\f$ \hat{q} = \hat{q}^{-1} \f$).
/*!\brief Inversion of the quaternion (\f$ \hat{q} = \hat{q}^{-1} \f$).
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment