Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-engine
Commits
f76f34d4
Commit
f76f34d4
authored
May 21, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加解码方法
parent
f7ff466e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
1 deletion
+38
-1
Matrix.ts
src/2d/math/Matrix.ts
+38
-1
No files found.
src/2d/math/Matrix.ts
View file @
f76f34d4
import
{
Point
}
from
"././Point"
;
import
{
HashObject
}
from
"../HashObject"
;
import
{
cos
,
DEG_TO_RAD
,
RAD_TO_DEG
,
sin
}
from
"../const"
;
import
{
cos
,
DEG_TO_RAD
,
PI_2
,
RAD_TO_DEG
,
sin
}
from
"../const"
;
import
Transform
from
"./Transform"
;
/**
* 2维矩阵
...
...
@@ -421,6 +422,42 @@ export class Matrix extends HashObject {
return
Math
.
round
(
Math
.
atan2
(
this
.
b
,
this
.
a
)
*
RAD_TO_DEG
);
}
decompose
(
transform
:
Transform
)
{
const
a
=
this
.
a
;
const
b
=
this
.
b
;
const
c
=
this
.
c
;
const
d
=
this
.
d
;
//取斜切
const
skewX
=
-
Math
.
atan2
(
-
c
,
d
);
const
skewY
=
Math
.
atan2
(
b
,
a
);
const
delta
=
Math
.
abs
(
skewX
+
skewY
);
//斜切值和旋转不唯一,所以设定条件只取其一
if
(
delta
<
0.00001
||
Math
.
abs
(
PI_2
-
delta
)
<
0.00001
)
{
transform
.
rotation
=
skewY
;
//考虑是否必要
if
(
a
<
0
&&
d
>=
0
)
{
transform
.
rotation
+=
(
transform
.
rotation
<=
0
)
?
Math
.
PI
:
-
Math
.
PI
;
}
transform
.
skew
.
x
=
transform
.
skew
.
y
=
0
;
}
else
{
transform
.
rotation
=
0
;
transform
.
skew
.
x
=
skewX
;
transform
.
skew
.
y
=
skewY
;
}
//取缩放
transform
.
scale
.
x
=
Math
.
sqrt
((
a
*
a
)
+
(
b
*
b
));
transform
.
scale
.
y
=
Math
.
sqrt
((
c
*
c
)
+
(
d
*
d
));
//取位置
transform
.
position
.
x
=
this
.
tx
;
transform
.
position
.
y
=
this
.
ty
;
return
transform
;
}
/**
* Creates an array from the current Matrix object.与glsl中的mat3对应,注意行列主序执行transpose;
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment