class_vector2.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Vector2:
  4. Vector2
  5. =======
  6. **Category:** Built-In Types
  7. Brief Description
  8. -----------------
  9. Vector used for 2D Math.
  10. Member Functions
  11. ----------------
  12. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  13. | :ref:`float<class_float>` | :ref:`angle<class_Vector2_angle>` **(** **)** |
  14. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`float<class_float>` | :ref:`angle_to<class_Vector2_angle_to>` **(** :ref:`Vector2<class_vector2>` to **)** |
  16. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`float<class_float>` | :ref:`angle_to_point<class_Vector2_angle_to_point>` **(** :ref:`Vector2<class_vector2>` to **)** |
  18. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Vector2<class_vector2>` | :ref:`cubic_interpolate<class_Vector2_cubic_interpolate>` **(** :ref:`Vector2<class_vector2>` b, :ref:`Vector2<class_vector2>` pre_a, :ref:`Vector2<class_vector2>` post_b, :ref:`float<class_float>` t **)** |
  20. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector2_distance_squared_to>` **(** :ref:`Vector2<class_vector2>` to **)** |
  22. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector2_distance_to>` **(** :ref:`Vector2<class_vector2>` to **)** |
  24. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`dot<class_Vector2_dot>` **(** :ref:`Vector2<class_vector2>` with **)** |
  26. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Vector2<class_vector2>` | :ref:`floor<class_Vector2_floor>` **(** **)** |
  28. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Vector2<class_vector2>` | :ref:`floorf<class_Vector2_floorf>` **(** **)** |
  30. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`get_aspect<class_Vector2_get_aspect>` **(** **)** |
  32. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`length<class_Vector2_length>` **(** **)** |
  34. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector2_length_squared>` **(** **)** |
  36. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Vector2<class_vector2>` | :ref:`linear_interpolate<class_Vector2_linear_interpolate>` **(** :ref:`Vector2<class_vector2>` b, :ref:`float<class_float>` t **)** |
  38. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Vector2<class_vector2>` | :ref:`normalized<class_Vector2_normalized>` **(** **)** |
  40. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Vector2<class_vector2>` | :ref:`reflect<class_Vector2_reflect>` **(** :ref:`Vector2<class_vector2>` vec **)** |
  42. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Vector2<class_vector2>` | :ref:`rotated<class_Vector2_rotated>` **(** :ref:`float<class_float>` phi **)** |
  44. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Vector2<class_vector2>` | :ref:`slide<class_Vector2_slide>` **(** :ref:`Vector2<class_vector2>` vec **)** |
  46. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Vector2<class_vector2>` | :ref:`snapped<class_Vector2_snapped>` **(** :ref:`Vector2<class_vector2>` by **)** |
  48. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Vector2<class_vector2>` | :ref:`tangent<class_Vector2_tangent>` **(** **)** |
  50. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector2<class_vector2>` | :ref:`Vector2<class_Vector2_Vector2>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)** |
  52. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. Member Variables
  54. ----------------
  55. - :ref:`float<class_float>` **x**
  56. - :ref:`float<class_float>` **y**
  57. - :ref:`float<class_float>` **width**
  58. - :ref:`float<class_float>` **height**
  59. Member Function Description
  60. ---------------------------
  61. .. _class_Vector2_angle:
  62. - :ref:`float<class_float>` **angle** **(** **)**
  63. Returns the result of atan2 when called with the Vector's x and y as parameters (Math::atan2(x,y)).
  64. Be aware that it therefore returns an angle oriented clockwise with regard to the (0, 1) unit vector, and not an angle oriented counter-clockwise with regard to the (1, 0) unit vector (which would be the typical trigonometric representation of the angle when calling Math::atan2(y,x)).
  65. .. _class_Vector2_angle_to:
  66. - :ref:`float<class_float>` **angle_to** **(** :ref:`Vector2<class_vector2>` to **)**
  67. Returns the angle in radians between the two vectors.
  68. .. _class_Vector2_angle_to_point:
  69. - :ref:`float<class_float>` **angle_to_point** **(** :ref:`Vector2<class_vector2>` to **)**
  70. Returns the angle in radians between the line connecting the two points and the x coordinate.
  71. .. _class_Vector2_cubic_interpolate:
  72. - :ref:`Vector2<class_vector2>` **cubic_interpolate** **(** :ref:`Vector2<class_vector2>` b, :ref:`Vector2<class_vector2>` pre_a, :ref:`Vector2<class_vector2>` post_b, :ref:`float<class_float>` t **)**
  73. Cubicly interpolates between this Vector and "b", using "pre_a" and "post_b" as handles, and returning the result at position "t".
  74. .. _class_Vector2_distance_squared_to:
  75. - :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector2<class_vector2>` to **)**
  76. Returns the squared distance to vector "b". Prefer this function over "distance_to" if you need to sort vectors or need the squared distance for some formula.
  77. .. _class_Vector2_distance_to:
  78. - :ref:`float<class_float>` **distance_to** **(** :ref:`Vector2<class_vector2>` to **)**
  79. Returns the distance to vector "b".
  80. .. _class_Vector2_dot:
  81. - :ref:`float<class_float>` **dot** **(** :ref:`Vector2<class_vector2>` with **)**
  82. Returns the dot product with vector "b".
  83. .. _class_Vector2_floor:
  84. - :ref:`Vector2<class_vector2>` **floor** **(** **)**
  85. Remove the fractional part of x and y.
  86. .. _class_Vector2_floorf:
  87. - :ref:`Vector2<class_vector2>` **floorf** **(** **)**
  88. .. _class_Vector2_get_aspect:
  89. - :ref:`float<class_float>` **get_aspect** **(** **)**
  90. Returns the ratio of X to Y.
  91. .. _class_Vector2_length:
  92. - :ref:`float<class_float>` **length** **(** **)**
  93. Returns the length of the vector.
  94. .. _class_Vector2_length_squared:
  95. - :ref:`float<class_float>` **length_squared** **(** **)**
  96. Returns the squared length of the vector. Prefer this function over "length" if you need to sort vectors or need the squared length for some formula.
  97. .. _class_Vector2_linear_interpolate:
  98. - :ref:`Vector2<class_vector2>` **linear_interpolate** **(** :ref:`Vector2<class_vector2>` b, :ref:`float<class_float>` t **)**
  99. Returns the result of the linear interpolation between this vector and "b", by amount "t".
  100. .. _class_Vector2_normalized:
  101. - :ref:`Vector2<class_vector2>` **normalized** **(** **)**
  102. Returns a normalized vector to unit length.
  103. .. _class_Vector2_reflect:
  104. - :ref:`Vector2<class_vector2>` **reflect** **(** :ref:`Vector2<class_vector2>` vec **)**
  105. Like "slide", but reflects the Vector instead of continuing along the wall.
  106. .. _class_Vector2_rotated:
  107. - :ref:`Vector2<class_vector2>` **rotated** **(** :ref:`float<class_float>` phi **)**
  108. Rotates the vector by "phi" radians.
  109. .. _class_Vector2_slide:
  110. - :ref:`Vector2<class_vector2>` **slide** **(** :ref:`Vector2<class_vector2>` vec **)**
  111. Slides the vector by the other vector.
  112. .. _class_Vector2_snapped:
  113. - :ref:`Vector2<class_vector2>` **snapped** **(** :ref:`Vector2<class_vector2>` by **)**
  114. Snaps the vector to a grid with the given size.
  115. .. _class_Vector2_tangent:
  116. - :ref:`Vector2<class_vector2>` **tangent** **(** **)**
  117. Returns a perpendicular vector.
  118. .. _class_Vector2_Vector2:
  119. - :ref:`Vector2<class_vector2>` **Vector2** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
  120. Constructs a new Vector2 from the given x and y.