Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-core
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
劳工
scilla-core
Commits
a158773f
Commit
a158773f
authored
May 08, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加toObj返回简单数据对象
parent
168e9845
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
Vector2D.ts
src/support/Vector2D.ts
+9
-5
No files found.
src/support/Vector2D.ts
View file @
a158773f
...
...
@@ -33,7 +33,7 @@ export function releaseVector2D(target) {
/**
* 2D矢量
*/
export
default
class
Vector2D
extends
HashObject
{
export
default
class
Vector2D
extends
HashObject
{
private
_x
:
number
;
private
_y
:
number
;
private
onChange
:
Function
;
...
...
@@ -44,7 +44,7 @@ export default class Vector2D extends HashObject{
* @param y y分量
* @param onChange 当改变时触发
*/
constructor
(
x
:
number
=
0
,
y
:
number
=
0
,
onChange
?:
Function
)
{
constructor
(
x
:
number
=
0
,
y
:
number
=
0
,
onChange
?:
Function
)
{
super
();
this
.
onChange
=
onChange
;
...
...
@@ -91,7 +91,7 @@ export default class Vector2D extends HashObject{
* @param x
* @param y
*/
setXY
(
x
:
number
=
0
,
y
:
number
=
0
):
Vector2D
{
setXY
(
x
:
number
=
0
,
y
:
number
=
0
):
Vector2D
{
this
.
x
=
x
;
this
.
y
=
y
;
...
...
@@ -229,7 +229,7 @@ export default class Vector2D extends HashObject{
* 向量乘于某个数
* @param value
*/
multiply
(
value
:
number
):
Vector2D
{
multiply
(
value
:
number
):
Vector2D
{
this
.
x
*=
value
;
this
.
y
*=
value
;
return
this
;
...
...
@@ -239,7 +239,7 @@ export default class Vector2D extends HashObject{
* 向量除于某个数
* @param value
*/
divide
(
value
:
number
):
Vector2D
{
divide
(
value
:
number
):
Vector2D
{
this
.
x
/=
value
;
this
.
y
/=
value
;
return
this
;
...
...
@@ -309,6 +309,10 @@ export default class Vector2D extends HashObject{
return
"[Vector2D (x:"
+
this
.
x
+
", y:"
+
this
.
y
+
")]"
;
}
toObj
()
{
return
{
x
:
this
.
x
,
y
:
this
.
y
}
}
static
corner
(
v1
,
v2
)
{
return
Math
.
acos
(
v1
.
dotProd
(
v2
)
/
(
v1
.
length
*
v2
.
length
));
}
...
...
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