Vector4.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. Vector4 - 4D vector
  2. -------------------
  3. .. ...............................................................................
  4. .. rubric:: Constructor
  5. .. ...............................................................................
  6. .. class:: Vector4( x, y, z, w )
  7. 4D vector
  8. :param float x: x-coordinate
  9. :param float y: y-coordinate
  10. :param float z: z-coordinate
  11. :param float w: w-coordinate
  12. .. ...............................................................................
  13. .. rubric:: Attributes
  14. .. ...............................................................................
  15. .. attribute:: Vector4.x
  16. float - default ``0``
  17. .. attribute:: Vector4.y
  18. float - default ``0``
  19. .. attribute:: Vector4.z
  20. float - default ``0``
  21. .. attribute:: Vector4.w
  22. float - default ``1``
  23. .. ...............................................................................
  24. .. rubric:: Methods
  25. .. ...............................................................................
  26. .. function:: Vector4.clone( )
  27. Clones this vector
  28. :returns: New instance identical to this vector
  29. :rtype: :class:`Vector4`
  30. .. function:: Vector4.set( x, y, z, w )
  31. Sets value of this vector
  32. :param float x: x-coordinate
  33. :param float y: y-coordinate
  34. :param float z: z-coordinate
  35. :param float w: w-coordinate
  36. :returns: This vector
  37. :rtype: :class:`Vector4`
  38. .. function:: Vector4.copy( v )
  39. Copies value of ``v`` to this vector
  40. Sets ``w`` to 1 if ``v.w`` is undefined
  41. :param Vector4 v: source vector
  42. :returns: This vector
  43. :rtype: :class:`Vector4`
  44. .. function:: Vector4.add( v1, v2 )
  45. Sets this vector to ``v1 + v2``
  46. :param Vector4 v1: source vector 1
  47. :param Vector4 v2: source vector 2
  48. :returns: This vector
  49. :rtype: :class:`Vector4`
  50. .. function:: Vector4.addSelf( v )
  51. Adds ``v`` to this vector
  52. :param Vector4 v: source vector
  53. :returns: This vector
  54. :rtype: :class:`Vector4`
  55. .. function:: Vector4.sub( v1, v2 )
  56. Sets this vector to ``v1 - v2``
  57. :param Vector4 v1: source vector 1
  58. :param Vector4 v2: source vector 2
  59. .. function:: Vector4.subSelf( v )
  60. Subtracts ``v`` from this vector
  61. :param Vector4 v: source vector
  62. :returns: This vector
  63. :rtype: :class:`Vector4`
  64. .. function:: Vector4.multiplyScalar( s )
  65. Multiplies this vector by scalar ``s``
  66. :param float s: scalar
  67. :returns: This vector
  68. :rtype: :class:`Vector4`
  69. .. function:: Vector4.divideScalar( s )
  70. Divides this vector by scalar ``s``
  71. Set vector to ``( 0, 0, 0, 1 )`` if ``s == 0``
  72. :param float s: scalar
  73. :returns: This vector
  74. :rtype: :class:`Vector4`
  75. .. function:: Vector4.negate( )
  76. Inverts this vector
  77. :returns: This vector
  78. :rtype: :class:`Vector4`
  79. .. function:: Vector4.dot( v )
  80. Computes dot product of this vector and ``v``
  81. :param Vector4 v: vector
  82. :returns: dot product
  83. :rtype: float
  84. .. function:: Vector4.lengthSq( )
  85. Computes squared length of this vector
  86. :returns: squared length
  87. :rtype: float
  88. .. function:: Vector4.length( )
  89. Computes length of this vector
  90. :returns: length
  91. :rtype: float
  92. .. function:: Vector4.normalize( )
  93. Normalizes this vector
  94. :returns: This vector
  95. :rtype: :class:`Vector4`
  96. .. function:: Vector4.setLength( l )
  97. Normalizes this vector and multiplies it by ``l``
  98. :returns: This vector
  99. :rtype: :class:`Vector4`
  100. .. function:: Vector4.lerpSelf( v, alpha )
  101. Linearly interpolate between this vector and ``v`` with ``alpha`` factor
  102. :param Vector4 v: vector
  103. :param float alpha: interpolation factor
  104. :returns: This vector
  105. :rtype: :class:`Vector4`
  106. .. ...............................................................................
  107. .. rubric:: Example
  108. .. ...............................................................................
  109. ::
  110. var a = new THREE.Vector4( 1, 0, 0, 0 );