Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fktz008
three.js
提交
5030e6e1
T
three.js
项目概览
fktz008
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5030e6e1
编写于
3月 05, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Docs: Quaternion.
上级
b27fa8e6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
119 addition
and
204 deletion
+119
-204
docs/api/core/Matrix4.html
docs/api/core/Matrix4.html
+1
-1
docs/api/core/Quaternion.html
docs/api/core/Quaternion.html
+91
-7
docs/api/core/Quaternion.rst
docs/api/core/Quaternion.rst
+0
-169
src/core/Quaternion.js
src/core/Quaternion.js
+27
-27
未找到文件。
docs/api/core/Matrix4.html
浏览文件 @
5030e6e1
...
...
@@ -303,7 +303,7 @@ Clones this matrix.
</div>
<h2>
Static
M
ethods
</h2>
<h2>
Static
m
ethods
</h2>
<h3>
.makeInvert3x3( [page:Matrix4 m] ) [page:Matrix3]
</h3>
<div>
...
...
docs/api/core/Quaternion.html
浏览文件 @
5030e6e1
...
...
@@ -3,27 +3,103 @@
<div
class=
"desc"
>
Implementation of a quaternion
</div>
<h2>
Example
</h2>
<code>
var q = new THREE.Quaternion();
q.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
var v = new THREE.Vector3( 1, 0, 0 );
q.multiplyVector3( v );
</code>
<h2>
Constructor
</h2>
<h3>
[name]( [page:Number x], [page:Number y], [page:Number z], [page:Number w] )
</h3>
<h3>
[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )
</h3>
<div>
x - x coordinate
<br
/>
y - y coordinate
<br
/>
z - z coordinate
<br
/>
w - w coordinate
</div>
<h2>
Properties
</h2>
<h3>
.[page:
Number
x]
</h3>
<h3>
.[page:
Float
x]
</h3>
<h3>
.[page:
Number
y]
</h3>
<h3>
.[page:
Float
y]
</h3>
<h3>
.[page:
Number
z]
</h3>
<h3>
.[page:
Float
z]
</h3>
<h3>
.[page:
Number
w]
</h3>
<h3>
.[page:
Float
w]
</h3>
<h2>
Methods
</h2>
<h3>
.copy( q ) [page:Quaternion]
</h3>
<h3>
.set( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Quaternion]
</h3>
<div>
Sets values of this quaternion.
</div>
<h3>
.copy( [page:Quaternion q] ) [page:Quaternion]
</h3>
<div>
Copies values of *q* to this quaternion.
</div>
<h3>
.setFromEuler( [page:Vector3 vector] ) [page:Quaternion]
</h3>
<div>
Sets this quaternion from rotation specified by Euler angles.
</div>
<h3>
.setFromAxisAngle( [page:Vector3 axis], [page:Float angle] ) [page:Quaternion]
</h3>
<div>
Sets this quaternion from rotation specified by axis and angle.
<br
/>
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm].
<br
/>
*Axis* have to be normalized, *angle* is in radians.
</div>
<h3>
.setFromRotationMatrix( [page:Matrix4 m] ) [page:Quaternion]
</h3>
<div>
Sets this quaternion from rotation component of *m*.
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].
</div>
<h3>
.calculateW() [page:Quaternion]
</h3>
<div>
Calculates *w* component of this quaternion.
</div>
<h3>
.inverse() [page:Quaternion]
</h3>
<div>
Inverts this quaternion.
</div>
<h3>
.length() [page:Float]
</h3>
<div>
Computes length of this quaternion.
</div>
<h3>
.normalize() [page:Quaternion]
</h3>
<div>
Normalizes this quaternion.
</div>
<h3>
.multiply( [page:Quaternion a], [page:Quaternion b] ) [page:Quaternion]
</h3>
<div>
Copies value of *q* to this quaternion.
Sets this quaternion to *a x b*
<br
/>
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm].
</div>
<h3>
.multiplySelf( [page:Quaternion b] ) [page:Quaternion]
</h3>
<div>
Multiplies this quaternion by *b*.
</div>
<h3>
.multiplyVector3( [page:Vector3 vector], [page:Vector3 dest] ) [page:Quaternion]
</h3>
<div>
Rotates *vector* by this quaternion into *dest*.
<br
/>
If *dest* is not specified, result goes to *vec*.
</div>
<h3>
.clone() [page:Quaternion]
</h3>
...
...
@@ -32,6 +108,14 @@ Clones this quaternion.
</div>
<h2>
Static methods
</h2>
<h3>
.slerp( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] ) [page:Quaternion]
</h3>
<div>
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].
</div>
<h2>
Source
</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
\ No newline at end of file
docs/api/core/Quaternion.rst
已删除
100644 → 0
浏览文件 @
b27fa8e6
Quaternion - Implementation of a quaternion
-------------------------------------------
.. ...............................................................................
.. rubric:: Constructor
.. ...............................................................................
.. class:: Quaternion( x, y, z, w )
Implementation of a quaternion
:param float x: x-coordinate
:param float y: y-coordinate
:param float z: z-coordinate
:param float w: w-coordinate
.. ...............................................................................
.. rubric:: Attributes
.. ...............................................................................
.. attribute:: Quaternion.x
float - default ``0``
.. attribute:: Quaternion.y
float - default ``0``
.. attribute:: Quaternion.z
float - default ``0``
.. attribute:: Quaternion.w
float - default ``1``
.. ...............................................................................
.. rubric:: Methods
.. ...............................................................................
.. function:: Quaternion.clone( )
Clones this quaternion
:returns: New instance identical to this quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.set( x, y, z, w )
Sets value of this vector
:param float x: x-coordinate
:param float y: y-coordinate
:param float z: z-coordinate
:param float w: w-coordinate
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.copy( q )
Copies value of ``q`` to this quaternion
:param Quaternion v: source quaternion
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.setFromEuler ( vec3 )
Sets this quaternion from rotation specified by Euler angles
Angles are in degrees
:param Vector3 vec3: Euler angles vector
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.setFromAxisAngle ( axis, angle )
Sets this quaternion from rotation specified by axis and angle
Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
Axis have to be normalized, angle is in radians
:param Vector3 axis: axis vector
:param float angle: angle
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.setFromRotationMatrix ( m )
Sets this quaternion from rotation specified by matrix
Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
:param Matrix4 m: rotation matrix
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.calculateW( )
Calculates ``w`` component of this quaternion
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.inverse( )
Inverts this quaternion
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.length( )
Computes length of this quaternion
:returns: length
:rtype: float
.. function:: Quaternion.normalize( )
Normalizes this quaternion
:returns: This vector
:rtype: :class:`Quaternion`
.. function:: Quaternion.multiplySelf( quat2 )
Multiplies this quaternion by ``quat2``
:param Quaternion quat2: quaternion
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.multiply( q1, q2 )
Sets this quaternion to ``q1 * q2``
Adapted from: http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
:param Quaternion q1: quaternion 1
:param Quaternion q2: quaternion 2
:returns: This quaternion
:rtype: :class:`Quaternion`
.. function:: Quaternion.multiplyVector3( vec, dest )
Rotates ``vec`` by this quaternion into ``dest``
If ``dest`` is not specified, result goes to ``vec``
:param Vector3 vec: source vector
:param Vector3 dest: destination vector
:returns: Rotated vector
:rtype: :class:`Vector3`
.. ...............................................................................
.. rubric:: Example
.. ...............................................................................
::
var q = new THREE.Quaternion();
q.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
var v = new THREE.Vector3( 1, 0, 0 );
q.multiplyVector3( v );
src/core/Quaternion.js
浏览文件 @
5030e6e1
...
...
@@ -38,18 +38,12 @@ THREE.Quaternion.prototype = {
},
clone
:
function
()
{
return
new
THREE
.
Quaternion
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
w
);
},
setFromEuler
:
function
(
vec3
)
{
setFromEuler
:
function
(
vector
)
{
var
c
=
Math
.
PI
/
360
,
// 0.5 * Math.PI / 360, // 0.5 is an optimization
x
=
vec
3
.
x
*
c
,
y
=
vec
3
.
y
*
c
,
z
=
vec
3
.
z
*
c
,
x
=
vec
tor
.
x
*
c
,
y
=
vec
tor
.
y
*
c
,
z
=
vec
tor
.
z
*
c
,
c1
=
Math
.
cos
(
y
),
s1
=
Math
.
sin
(
y
),
...
...
@@ -161,41 +155,41 @@ THREE.Quaternion.prototype = {
},
multiply
Self
:
function
(
quat2
)
{
multiply
:
function
(
a
,
b
)
{
var
qax
=
this
.
x
,
qay
=
this
.
y
,
qaz
=
this
.
z
,
qaw
=
this
.
w
,
qbx
=
quat2
.
x
,
qby
=
quat2
.
y
,
qbz
=
quat2
.
z
,
qbw
=
quat2
.
w
;
// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
this
.
x
=
qax
*
qbw
+
qaw
*
qbx
+
qay
*
qbz
-
qaz
*
qby
;
this
.
y
=
qay
*
qbw
+
qaw
*
qby
+
qaz
*
qbx
-
qax
*
qbz
;
this
.
z
=
qaz
*
qbw
+
qaw
*
qbz
+
qax
*
qby
-
qay
*
qbx
;
this
.
w
=
qaw
*
qbw
-
qax
*
qbx
-
qay
*
qby
-
qaz
*
qbz
;
this
.
x
=
a
.
x
*
b
.
w
+
a
.
y
*
b
.
z
-
a
.
z
*
b
.
y
+
a
.
w
*
b
.
x
;
this
.
y
=
-
a
.
x
*
b
.
z
+
a
.
y
*
b
.
w
+
a
.
z
*
b
.
x
+
a
.
w
*
b
.
y
;
this
.
z
=
a
.
x
*
b
.
y
-
a
.
y
*
b
.
x
+
a
.
z
*
b
.
w
+
a
.
w
*
b
.
z
;
this
.
w
=
-
a
.
x
*
b
.
x
-
a
.
y
*
b
.
y
-
a
.
z
*
b
.
z
+
a
.
w
*
b
.
w
;
return
this
;
},
multiply
:
function
(
q1
,
q2
)
{
multiply
Self
:
function
(
b
)
{
// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
var
qax
=
this
.
x
,
qay
=
this
.
y
,
qaz
=
this
.
z
,
qaw
=
this
.
w
,
qbx
=
b
.
x
,
qby
=
b
.
y
,
qbz
=
b
.
z
,
qbw
=
b
.
w
;
this
.
x
=
q1
.
x
*
q2
.
w
+
q1
.
y
*
q2
.
z
-
q1
.
z
*
q2
.
y
+
q1
.
w
*
q2
.
x
;
this
.
y
=
-
q1
.
x
*
q2
.
z
+
q1
.
y
*
q2
.
w
+
q1
.
z
*
q2
.
x
+
q1
.
w
*
q2
.
y
;
this
.
z
=
q1
.
x
*
q2
.
y
-
q1
.
y
*
q2
.
x
+
q1
.
z
*
q2
.
w
+
q1
.
w
*
q2
.
z
;
this
.
w
=
-
q1
.
x
*
q2
.
x
-
q1
.
y
*
q2
.
y
-
q1
.
z
*
q2
.
z
+
q1
.
w
*
q2
.
w
;
this
.
x
=
qax
*
qbw
+
qaw
*
qbx
+
qay
*
qbz
-
qaz
*
qby
;
this
.
y
=
qay
*
qbw
+
qaw
*
qby
+
qaz
*
qbx
-
qax
*
qbz
;
this
.
z
=
qaz
*
qbw
+
qaw
*
qbz
+
qax
*
qby
-
qay
*
qbx
;
this
.
w
=
qaw
*
qbw
-
qax
*
qbx
-
qay
*
qby
-
qaz
*
qbz
;
return
this
;
},
multiplyVector3
:
function
(
vec
,
dest
)
{
multiplyVector3
:
function
(
vec
tor
,
dest
)
{
if
(
!
dest
)
{
dest
=
vec
;
}
if
(
!
dest
)
{
dest
=
vec
tor
;
}
var
x
=
vec
.
x
,
y
=
vec
.
y
,
z
=
vec
.
z
,
var
x
=
vec
tor
.
x
,
y
=
vector
.
y
,
z
=
vector
.
z
,
qx
=
this
.
x
,
qy
=
this
.
y
,
qz
=
this
.
z
,
qw
=
this
.
w
;
// calculate quat * vec
// calculate quat * vec
tor
var
ix
=
qw
*
x
+
qy
*
z
-
qz
*
y
,
iy
=
qw
*
y
+
qz
*
x
-
qx
*
z
,
...
...
@@ -210,6 +204,12 @@ THREE.Quaternion.prototype = {
return
dest
;
},
clone
:
function
()
{
return
new
THREE
.
Quaternion
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
w
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录