Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minity
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Matias.Sunde
minity
Commits
9bfb1f78
Commit
9bfb1f78
authored
3 years ago
by
Anders Syvertsen
Browse files
Options
Downloads
Patches
Plain Diff
Added a matrix decomposition utility function
parent
289bc515
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Viewer.cpp
+19
-0
19 additions, 0 deletions
src/Viewer.cpp
src/Viewer.h
+10
-2
10 additions, 2 deletions
src/Viewer.h
with
29 additions
and
2 deletions
src/Viewer.cpp
+
19
−
0
View file @
9bfb1f78
...
...
@@ -452,3 +452,22 @@ void Viewer::mainMenu()
ImGui
::
EndMenu
();
}
}
namespace
minity
{
void
matrixDecompose
(
const
glm
::
mat4
&
matrix
,
glm
::
vec3
&
translation
,
glm
::
mat4
&
rotation
,
glm
::
vec3
&
scale
)
{
translation
=
glm
::
vec3
{
matrix
[
3
]};
glm
::
mat3
inner
=
glm
::
mat3
{
matrix
};
scale
.
x
=
glm
::
length
(
inner
[
0
]);
scale
.
y
=
glm
::
length
(
inner
[
1
]);
scale
.
z
=
glm
::
length
(
inner
[
2
]);
inner
[
0
]
/=
scale
.
x
;
inner
[
1
]
/=
scale
.
y
;
inner
[
2
]
/=
scale
.
z
;
rotation
=
glm
::
mat4
{
inner
};
}
}
This diff is collapsed.
Click to expand it.
src/Viewer.h
+
10
−
2
View file @
9bfb1f78
...
...
@@ -14,7 +14,6 @@
namespace
minity
{
class
Viewer
{
public:
...
...
@@ -78,5 +77,14 @@ namespace minity
bool
m_saveScreenshot
=
false
;
};
/**
* @brief Performs standard decomposition of a transformation matrix into translation, rotation and scale parts respectively.
* Note: The out rotation is an affine space rotation matrix, meaning only the inner 3x3 part affects rotation and the rest is the identity matrix.
* @see https://math.stackexchange.com/questions/237369/given-this-transformation-matrix-how-do-i-decompose-it-into-translation-rotati
* @param matrix The matrix to decompose
* @param translation Out parameter for translation
* @param rotation Out parameter for rotation
* @param scale Out parameter for scale
*/
void
matrixDecompose
(
const
glm
::
mat4
&
matrix
,
glm
::
vec3
&
translation
,
glm
::
mat4
&
rotation
,
glm
::
vec3
&
scale
);
}
\ No newline at end of file
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