class_vector3.rst 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Vector3.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Vector3:
  6. Vector3
  7. =======
  8. Vector used for 3D math using floating point coordinates.
  9. Description
  10. -----------
  11. 3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.
  12. It uses floating point coordinates.
  13. Tutorials
  14. ---------
  15. - :doc:`../tutorials/math/index`
  16. Properties
  17. ----------
  18. +---------------------------+------------------------------------+---------+
  19. | :ref:`float<class_float>` | :ref:`x<class_Vector3_property_x>` | ``0.0`` |
  20. +---------------------------+------------------------------------+---------+
  21. | :ref:`float<class_float>` | :ref:`y<class_Vector3_property_y>` | ``0.0`` |
  22. +---------------------------+------------------------------------+---------+
  23. | :ref:`float<class_float>` | :ref:`z<class_Vector3_property_z>` | ``0.0`` |
  24. +---------------------------+------------------------------------+---------+
  25. Methods
  26. -------
  27. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_method_Vector3>` **(** :ref:`Vector3i<class_Vector3i>` from **)** |
  29. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Vector3<class_Vector3>` | :ref:`Vector3<class_Vector3_method_Vector3>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)** |
  31. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector3<class_Vector3>` | :ref:`abs<class_Vector3_method_abs>` **(** **)** |
  33. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`angle_to<class_Vector3_method_angle_to>` **(** :ref:`Vector3<class_Vector3>` to **)** |
  35. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Vector3<class_Vector3>` | :ref:`bounce<class_Vector3_method_bounce>` **(** :ref:`Vector3<class_Vector3>` n **)** |
  37. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Vector3<class_Vector3>` | :ref:`ceil<class_Vector3_method_ceil>` **(** **)** |
  39. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Vector3<class_Vector3>` | :ref:`cross<class_Vector3_method_cross>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  41. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Vector3<class_Vector3>` | :ref:`cubic_interpolate<class_Vector3_method_cubic_interpolate>` **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` t **)** |
  43. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Vector3<class_Vector3>` | :ref:`direction_to<class_Vector3_method_direction_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  45. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`distance_squared_to<class_Vector3_method_distance_squared_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  47. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`distance_to<class_Vector3_method_distance_to>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  49. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`dot<class_Vector3_method_dot>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  51. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Vector3<class_Vector3>` | :ref:`floor<class_Vector3_method_floor>` **(** **)** |
  53. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Vector3<class_Vector3>` | :ref:`inverse<class_Vector3_method_inverse>` **(** **)** |
  55. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Vector3_method_is_equal_approx>` **(** :ref:`Vector3<class_Vector3>` v **)** |
  57. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`bool<class_bool>` | :ref:`is_normalized<class_Vector3_method_is_normalized>` **(** **)** |
  59. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`float<class_float>` | :ref:`length<class_Vector3_method_length>` **(** **)** |
  61. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`float<class_float>` | :ref:`length_squared<class_Vector3_method_length_squared>` **(** **)** |
  63. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Vector3<class_Vector3>` | :ref:`linear_interpolate<class_Vector3_method_linear_interpolate>` **(** :ref:`Vector3<class_Vector3>` b, :ref:`float<class_float>` t **)** |
  65. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`int<class_int>` | :ref:`max_axis<class_Vector3_method_max_axis>` **(** **)** |
  67. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`int<class_int>` | :ref:`min_axis<class_Vector3_method_min_axis>` **(** **)** |
  69. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Vector3<class_Vector3>` | :ref:`move_toward<class_Vector3_method_move_toward>` **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` delta **)** |
  71. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Vector3<class_Vector3>` | :ref:`normalized<class_Vector3_method_normalized>` **(** **)** |
  73. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Basis<class_Basis>` | :ref:`outer<class_Vector3_method_outer>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  75. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Vector3<class_Vector3>` | :ref:`posmod<class_Vector3_method_posmod>` **(** :ref:`float<class_float>` mod **)** |
  77. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Vector3<class_Vector3>` | :ref:`posmodv<class_Vector3_method_posmodv>` **(** :ref:`Vector3<class_Vector3>` modv **)** |
  79. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector3<class_Vector3>` | :ref:`project<class_Vector3_method_project>` **(** :ref:`Vector3<class_Vector3>` b **)** |
  81. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`Vector3<class_Vector3>` | :ref:`reflect<class_Vector3_method_reflect>` **(** :ref:`Vector3<class_Vector3>` n **)** |
  83. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Vector3<class_Vector3>` | :ref:`rotated<class_Vector3_method_rotated>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` phi **)** |
  85. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`Vector3<class_Vector3>` | :ref:`round<class_Vector3_method_round>` **(** **)** |
  87. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Vector3<class_Vector3>` | :ref:`sign<class_Vector3_method_sign>` **(** **)** |
  89. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`Vector3<class_Vector3>` | :ref:`slerp<class_Vector3_method_slerp>` **(** :ref:`Vector3<class_Vector3>` b, :ref:`float<class_float>` t **)** |
  91. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`Vector3<class_Vector3>` | :ref:`slide<class_Vector3_method_slide>` **(** :ref:`Vector3<class_Vector3>` n **)** |
  93. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`Vector3<class_Vector3>` | :ref:`snapped<class_Vector3_method_snapped>` **(** :ref:`Vector3<class_Vector3>` by **)** |
  95. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`Basis<class_Basis>` | :ref:`to_diagonal_matrix<class_Vector3_method_to_diagonal_matrix>` **(** **)** |
  97. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. Constants
  99. ---------
  100. .. _class_Vector3_constant_AXIS_X:
  101. .. _class_Vector3_constant_AXIS_Y:
  102. .. _class_Vector3_constant_AXIS_Z:
  103. .. _class_Vector3_constant_ZERO:
  104. .. _class_Vector3_constant_ONE:
  105. .. _class_Vector3_constant_INF:
  106. .. _class_Vector3_constant_LEFT:
  107. .. _class_Vector3_constant_RIGHT:
  108. .. _class_Vector3_constant_UP:
  109. .. _class_Vector3_constant_DOWN:
  110. .. _class_Vector3_constant_FORWARD:
  111. .. _class_Vector3_constant_BACK:
  112. - **AXIS_X** = **0** --- Enumerated value for the X axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
  113. - **AXIS_Y** = **1** --- Enumerated value for the Y axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
  114. - **AXIS_Z** = **2** --- Enumerated value for the Z axis. Returned by :ref:`max_axis<class_Vector3_method_max_axis>` and :ref:`min_axis<class_Vector3_method_min_axis>`.
  115. - **ZERO** = **Vector3( 0, 0, 0 )** --- Zero vector.
  116. - **ONE** = **Vector3( 1, 1, 1 )** --- One vector.
  117. - **INF** = **Vector3( inf, inf, inf )** --- Infinity vector.
  118. - **LEFT** = **Vector3( -1, 0, 0 )** --- Left unit vector.
  119. - **RIGHT** = **Vector3( 1, 0, 0 )** --- Right unit vector.
  120. - **UP** = **Vector3( 0, 1, 0 )** --- Up unit vector.
  121. - **DOWN** = **Vector3( 0, -1, 0 )** --- Down unit vector.
  122. - **FORWARD** = **Vector3( 0, 0, -1 )** --- Forward unit vector.
  123. - **BACK** = **Vector3( 0, 0, 1 )** --- Back unit vector.
  124. Property Descriptions
  125. ---------------------
  126. .. _class_Vector3_property_x:
  127. - :ref:`float<class_float>` **x**
  128. +-----------+---------+
  129. | *Default* | ``0.0`` |
  130. +-----------+---------+
  131. The vector's X component. Also accessible by using the index position ``[0]``.
  132. ----
  133. .. _class_Vector3_property_y:
  134. - :ref:`float<class_float>` **y**
  135. +-----------+---------+
  136. | *Default* | ``0.0`` |
  137. +-----------+---------+
  138. The vector's Y component. Also accessible by using the index position ``[1]``.
  139. ----
  140. .. _class_Vector3_property_z:
  141. - :ref:`float<class_float>` **z**
  142. +-----------+---------+
  143. | *Default* | ``0.0`` |
  144. +-----------+---------+
  145. The vector's Z component. Also accessible by using the index position ``[2]``.
  146. Method Descriptions
  147. -------------------
  148. .. _class_Vector3_method_Vector3:
  149. - :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`Vector3i<class_Vector3i>` from **)**
  150. Constructs a new ``Vector3`` from :ref:`Vector3i<class_Vector3i>`.
  151. ----
  152. - :ref:`Vector3<class_Vector3>` **Vector3** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)**
  153. Returns a ``Vector3`` with the given components.
  154. ----
  155. .. _class_Vector3_method_abs:
  156. - :ref:`Vector3<class_Vector3>` **abs** **(** **)**
  157. Returns a new vector with all components in absolute values (i.e. positive).
  158. ----
  159. .. _class_Vector3_method_angle_to:
  160. - :ref:`float<class_float>` **angle_to** **(** :ref:`Vector3<class_Vector3>` to **)**
  161. Returns the minimum angle to the given vector.
  162. ----
  163. .. _class_Vector3_method_bounce:
  164. - :ref:`Vector3<class_Vector3>` **bounce** **(** :ref:`Vector3<class_Vector3>` n **)**
  165. Returns the vector "bounced off" from a plane defined by the given normal.
  166. ----
  167. .. _class_Vector3_method_ceil:
  168. - :ref:`Vector3<class_Vector3>` **ceil** **(** **)**
  169. Returns a new vector with all components rounded up.
  170. ----
  171. .. _class_Vector3_method_cross:
  172. - :ref:`Vector3<class_Vector3>` **cross** **(** :ref:`Vector3<class_Vector3>` b **)**
  173. Returns the cross product with ``b``.
  174. ----
  175. .. _class_Vector3_method_cubic_interpolate:
  176. - :ref:`Vector3<class_Vector3>` **cubic_interpolate** **(** :ref:`Vector3<class_Vector3>` b, :ref:`Vector3<class_Vector3>` pre_a, :ref:`Vector3<class_Vector3>` post_b, :ref:`float<class_float>` t **)**
  177. Performs a cubic interpolation between vectors ``pre_a``, ``a``, ``b``, ``post_b`` (``a`` is current), by the given amount ``t``. ``t`` is in the range of ``0.0 - 1.0``, representing the amount of interpolation.
  178. ----
  179. .. _class_Vector3_method_direction_to:
  180. - :ref:`Vector3<class_Vector3>` **direction_to** **(** :ref:`Vector3<class_Vector3>` b **)**
  181. Returns the normalized vector pointing from this vector to ``b``.
  182. ----
  183. .. _class_Vector3_method_distance_squared_to:
  184. - :ref:`float<class_float>` **distance_squared_to** **(** :ref:`Vector3<class_Vector3>` b **)**
  185. Returns the squared distance to ``b``. Prefer this function over :ref:`distance_to<class_Vector3_method_distance_to>` if you need to sort vectors or need the squared distance for some formula.
  186. ----
  187. .. _class_Vector3_method_distance_to:
  188. - :ref:`float<class_float>` **distance_to** **(** :ref:`Vector3<class_Vector3>` b **)**
  189. Returns the distance to ``b``.
  190. ----
  191. .. _class_Vector3_method_dot:
  192. - :ref:`float<class_float>` **dot** **(** :ref:`Vector3<class_Vector3>` b **)**
  193. Returns the dot product with ``b``.
  194. ----
  195. .. _class_Vector3_method_floor:
  196. - :ref:`Vector3<class_Vector3>` **floor** **(** **)**
  197. Returns a new vector with all components rounded down.
  198. ----
  199. .. _class_Vector3_method_inverse:
  200. - :ref:`Vector3<class_Vector3>` **inverse** **(** **)**
  201. Returns the inverse of the vector. This is the same as ``Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )``.
  202. ----
  203. .. _class_Vector3_method_is_equal_approx:
  204. - :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Vector3<class_Vector3>` v **)**
  205. Returns ``true`` if this vector and ``v`` are approximately equal, by running :ref:`@GDScript.is_equal_approx<class_@GDScript_method_is_equal_approx>` on each component.
  206. ----
  207. .. _class_Vector3_method_is_normalized:
  208. - :ref:`bool<class_bool>` **is_normalized** **(** **)**
  209. Returns ``true`` if the vector is normalized.
  210. ----
  211. .. _class_Vector3_method_length:
  212. - :ref:`float<class_float>` **length** **(** **)**
  213. Returns the vector's length.
  214. ----
  215. .. _class_Vector3_method_length_squared:
  216. - :ref:`float<class_float>` **length_squared** **(** **)**
  217. Returns the vector's length squared. Prefer this function over :ref:`length<class_Vector3_method_length>` if you need to sort vectors or need the squared length for some formula.
  218. ----
  219. .. _class_Vector3_method_linear_interpolate:
  220. - :ref:`Vector3<class_Vector3>` **linear_interpolate** **(** :ref:`Vector3<class_Vector3>` b, :ref:`float<class_float>` t **)**
  221. Returns the result of the linear interpolation between this vector and ``b`` by amount ``t``. ``t`` is in the range of ``0.0 - 1.0``, representing the amount of interpolation..
  222. ----
  223. .. _class_Vector3_method_max_axis:
  224. - :ref:`int<class_int>` **max_axis** **(** **)**
  225. Returns the axis of the vector's largest value. See ``AXIS_*`` constants.
  226. ----
  227. .. _class_Vector3_method_min_axis:
  228. - :ref:`int<class_int>` **min_axis** **(** **)**
  229. Returns the axis of the vector's smallest value. See ``AXIS_*`` constants.
  230. ----
  231. .. _class_Vector3_method_move_toward:
  232. - :ref:`Vector3<class_Vector3>` **move_toward** **(** :ref:`Vector3<class_Vector3>` to, :ref:`float<class_float>` delta **)**
  233. Moves the vector toward ``to`` by the fixed ``delta`` amount.
  234. ----
  235. .. _class_Vector3_method_normalized:
  236. - :ref:`Vector3<class_Vector3>` **normalized** **(** **)**
  237. Returns the vector scaled to unit length. Equivalent to ``v / v.length()``.
  238. ----
  239. .. _class_Vector3_method_outer:
  240. - :ref:`Basis<class_Basis>` **outer** **(** :ref:`Vector3<class_Vector3>` b **)**
  241. Returns the outer product with ``b``.
  242. ----
  243. .. _class_Vector3_method_posmod:
  244. - :ref:`Vector3<class_Vector3>` **posmod** **(** :ref:`float<class_float>` mod **)**
  245. Returns a vector composed of the ``fposmod`` of this vector's components and ``mod``.
  246. ----
  247. .. _class_Vector3_method_posmodv:
  248. - :ref:`Vector3<class_Vector3>` **posmodv** **(** :ref:`Vector3<class_Vector3>` modv **)**
  249. Returns a vector composed of the ``fposmod`` of this vector's components and ``modv``'s components.
  250. ----
  251. .. _class_Vector3_method_project:
  252. - :ref:`Vector3<class_Vector3>` **project** **(** :ref:`Vector3<class_Vector3>` b **)**
  253. Returns the vector projected onto the vector ``b``.
  254. ----
  255. .. _class_Vector3_method_reflect:
  256. - :ref:`Vector3<class_Vector3>` **reflect** **(** :ref:`Vector3<class_Vector3>` n **)**
  257. Returns the vector reflected from a plane defined by the given normal.
  258. ----
  259. .. _class_Vector3_method_rotated:
  260. - :ref:`Vector3<class_Vector3>` **rotated** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` phi **)**
  261. Rotates the vector around a given axis by ``phi`` radians. The axis must be a normalized vector.
  262. ----
  263. .. _class_Vector3_method_round:
  264. - :ref:`Vector3<class_Vector3>` **round** **(** **)**
  265. Returns the vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
  266. ----
  267. .. _class_Vector3_method_sign:
  268. - :ref:`Vector3<class_Vector3>` **sign** **(** **)**
  269. Returns the vector with each component set to one or negative one, depending on the signs of the components.
  270. ----
  271. .. _class_Vector3_method_slerp:
  272. - :ref:`Vector3<class_Vector3>` **slerp** **(** :ref:`Vector3<class_Vector3>` b, :ref:`float<class_float>` t **)**
  273. Returns the result of spherical linear interpolation between this vector and ``b``, by amount ``t``. ``t`` is in the range of ``0.0 - 1.0``, representing the amount of interpolation.
  274. **Note:** Both vectors must be normalized.
  275. ----
  276. .. _class_Vector3_method_slide:
  277. - :ref:`Vector3<class_Vector3>` **slide** **(** :ref:`Vector3<class_Vector3>` n **)**
  278. Returns the component of the vector along a plane defined by the given normal.
  279. ----
  280. .. _class_Vector3_method_snapped:
  281. - :ref:`Vector3<class_Vector3>` **snapped** **(** :ref:`Vector3<class_Vector3>` by **)**
  282. Returns a copy of the vector snapped to the lowest neared multiple.
  283. ----
  284. .. _class_Vector3_method_to_diagonal_matrix:
  285. - :ref:`Basis<class_Basis>` **to_diagonal_matrix** **(** **)**
  286. Returns a diagonal matrix with the vector as main diagonal.