Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fyge_for_tb
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
王剑峰
fyge_for_tb
Commits
29c78446
Commit
29c78446
authored
Mar 07, 2022
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Spherical
parent
5226f5d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
index.ts
src/3d/index.ts
+1
-0
Spherical.ts
src/3d/math/Spherical.ts
+84
-0
No files found.
src/3d/index.ts
View file @
29c78446
...
...
@@ -9,6 +9,7 @@ export * from "./math/Matrix4";
export
*
from
"./math/Quaternion"
;
export
*
from
"./math/Vector2"
;
export
*
from
"./math/Vector3"
;
export
*
from
"./math/Spherical"
;
//几何
export
*
from
"./geometries"
...
...
src/3d/math/Spherical.ts
0 → 100644
View file @
29c78446
/**
* @author bhouston / http://clara.io
* @author WestLangley / http://github.com/WestLangley
*
* Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
*
* The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up.
* The azimuthal angle (theta) is measured from the positive z-axis.
*/
export
class
Spherical
{
radius
=
1.0
;
phi
=
0
;
theta
=
0
;
constructor
(
radius
=
1.0
,
phi
=
0
,
theta
=
0
)
{
this
.
radius
=
radius
;
this
.
phi
=
phi
;
// polar angle
this
.
theta
=
theta
;
// azimuthal angle
}
set
(
radius
,
phi
,
theta
)
{
this
.
radius
=
radius
;
this
.
phi
=
phi
;
this
.
theta
=
theta
;
return
this
;
}
clone
()
{
return
(
new
Spherical
()).
copy
(
this
);
}
copy
(
other
)
{
this
.
radius
=
other
.
radius
;
this
.
phi
=
other
.
phi
;
this
.
theta
=
other
.
theta
;
return
this
;
}
// restrict phi to be betwee EPS and PI-EPS
makeSafe
()
{
var
EPS
=
0.000001
;
this
.
phi
=
Math
.
max
(
EPS
,
Math
.
min
(
Math
.
PI
-
EPS
,
this
.
phi
));
return
this
;
}
setFromVector3
(
v
)
{
return
this
.
setFromCartesianCoords
(
v
.
x
,
v
.
y
,
v
.
z
);
}
setFromCartesianCoords
(
x
,
y
,
z
)
{
this
.
radius
=
Math
.
sqrt
(
x
*
x
+
y
*
y
+
z
*
z
);
if
(
this
.
radius
===
0
)
{
this
.
theta
=
0
;
this
.
phi
=
0
;
}
else
{
this
.
theta
=
Math
.
atan2
(
x
,
z
);
this
.
phi
=
Math
.
acos
(
FYGE
.
clamp
(
y
/
this
.
radius
,
-
1
,
1
));
}
return
this
;
}
}
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