Vector3.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. Vector3 - 3D vector
  2. -------------------
  3. .. ...............................................................................
  4. .. rubric:: Constructor
  5. .. ...............................................................................
  6. .. class:: Vector3()
  7. 3D vector
  8. :param float x: x-coordinate
  9. :param float y: y-coordinate
  10. :param float z: z-coordinate
  11. .. ...............................................................................
  12. .. rubric:: Attributes
  13. .. ...............................................................................
  14. .. attribute:: Vector3.x
  15. .. attribute:: Vector3.y
  16. .. attribute:: Vector3.z
  17. .. ...............................................................................
  18. .. rubric:: Methods
  19. .. ...............................................................................
  20. .. function:: Vector3.clone( )
  21. Clones this vector
  22. :returns: New instance identical to this vector
  23. :rtype: :class:`Vector3`
  24. .. function:: Vector3.set( x, y, z )
  25. Sets value of this vector
  26. :param float x: x-coordinate
  27. :param float y: y-coordinate
  28. :param float z: z-coordinate
  29. :returns: This vector
  30. :rtype: :class:`Vector3`
  31. .. function:: Vector3.setX( x )
  32. Sets x-value of this vector
  33. :param float x: x-coordinate
  34. :returns: This vector
  35. :rtype: :class:`Vector3`
  36. .. function:: Vector3.setY( y )
  37. Sets y-value of this vector
  38. :param float y: y-coordinate
  39. :returns: This vector
  40. :rtype: :class:`Vector3`
  41. .. function:: Vector3.setZ( z )
  42. Sets z-value of this vector
  43. :param float z: z-coordinate
  44. :returns: This vector
  45. :rtype: :class:`Vector3`
  46. .. function:: Vector3.copy( v )
  47. Copies value of ``v`` to this vector
  48. :param Vector3 v: source vector
  49. :returns: This vector
  50. :rtype: :class:`Vector3`
  51. .. function:: Vector3.add( v1, v2 )
  52. Sets this vector to ``v1 + v2``
  53. :param Vector3 v1: source vector 1
  54. :param Vector3 v2: source vector 2
  55. :returns: This vector
  56. :rtype: :class:`Vector3`
  57. .. function:: Vector3.addSelf( v )
  58. Adds ``v`` to this vector
  59. :param Vector3 v: source vector
  60. :returns: This vector
  61. :rtype: :class:`Vector3`
  62. .. function:: Vector3.sub( v1, v2 )
  63. Sets this vector to ``v1 - v2``
  64. :param Vector3 v1: source vector 1
  65. :param Vector3 v2: source vector 2
  66. .. function:: Vector3.subSelf( v )
  67. Subtracts ``v`` from this vector
  68. :param Vector3 v: source vector
  69. :returns: This vector
  70. :rtype: :class:`Vector3`
  71. .. function:: Vector3.multiplyScalar( s )
  72. Multiplies this vector by scalar ``s``
  73. :param float s: scalar
  74. :returns: This vector
  75. :rtype: :class:`Vector2`
  76. .. function:: Vector3.divideScalar( s )
  77. Divides this vector by scalar ``s``
  78. Set vector to ``( 0, 0, 0 )`` if ``s == 0``
  79. :param float s: scalar
  80. :returns: This vector
  81. :rtype: :class:`Vector3`
  82. .. function:: Vector3.negate( )
  83. Inverts this vector
  84. :returns: This vector
  85. :rtype: :class:`Vector3`
  86. .. function:: Vector3.dot( v )
  87. Computes dot product of this vector and ``v``
  88. :param Vector3 v: vector
  89. :returns: dot product
  90. :rtype: float
  91. .. function:: Vector3.lengthSq( )
  92. Computes squared length of this vector
  93. :returns: squared length
  94. :rtype: float
  95. .. function:: Vector3.length( )
  96. Computes length of this vector
  97. :returns: length
  98. :rtype: float
  99. .. function:: Vector3.lengthManhattan( )
  100. Computes Manhattan length of this vector
  101. http://en.wikipedia.org/wiki/Taxicab_geometry
  102. :returns: length
  103. :rtype: float
  104. .. function:: Vector3.normalize( )
  105. Normalizes this vector
  106. :returns: This vector
  107. :rtype: :class:`Vector3`
  108. .. function:: Vector3.distanceTo( v )
  109. Computes distance of this vector to ``v``
  110. :param Vector3 v: vector
  111. :returns: squared distance
  112. :rtype: float
  113. .. function:: Vector3.distanceToSquared( v )
  114. Computes squared distance of this vector to ``v``
  115. :param Vector3 v: vector
  116. :returns: squared distance
  117. :rtype: float
  118. .. function:: Vector3.setLength( l )
  119. Normalizes this vector and multiplies it by ``l``
  120. :returns: This vector
  121. :rtype: :class:`Vector3`
  122. .. function:: Vector3.cross( a, b )
  123. Sets this vector to cross product of ``a`` and ``b``
  124. :param Vector3 a: vector
  125. :param Vector3 b: vector
  126. :returns: This vector
  127. :rtype: :class:`Vector3`
  128. .. function:: Vector3.crossSelf( v )
  129. Sets this vector to cross product of itself and ``v``
  130. :param Vector3 v: vector
  131. :returns: This vector
  132. :rtype: :class:`Vector3`
  133. .. function:: Vector3.setPositionFromMatrix( m )
  134. Sets this vector extracting position from matrix transform
  135. :param Matrix4 m: matrix
  136. :returns: This vector
  137. :rtype: :class:`Vector3`
  138. .. function:: Vector3.setRotationFromMatrix( m )
  139. Sets this vector extracting Euler angles rotation from matrix transform
  140. :param Matrix4 m: matrix
  141. :returns: This vector
  142. :rtype: :class:`Vector3`
  143. .. function:: Vector3.equals( v )
  144. Checks for strict equality of this vector and ``v``
  145. :param Vector3 v: vector
  146. :returns: true if this vector equals ``v``
  147. :rtype: boolean
  148. .. function:: Vector3.isZero( )
  149. Checks if length of this vector is within small epsilon (``0.0001``)
  150. :returns: true if this vector is zero
  151. :rtype: boolean
  152. .. ...............................................................................
  153. .. rubric:: Example
  154. .. ...............................................................................
  155. ::
  156. var a = new THREE.Vector3( 1, 0, 0 );
  157. var b = new THREE.Vector3( 0, 1, 0 );
  158. var c = new THREE.Vector3();
  159. c.cross( a, b );
粤ICP备19079148号