class_basis.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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_Basis:
  4. Basis
  5. =====
  6. **Category:** Built-In Types
  7. Brief Description
  8. -----------------
  9. 3x3 matrix datatype.
  10. Member Functions
  11. ----------------
  12. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  13. | :ref:`Basis<class_basis>` | :ref:`Basis<class_Basis_Basis>` **(** :ref:`Quat<class_quat>` from **)** |
  14. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`Basis<class_basis>` | :ref:`Basis<class_Basis_Basis>` **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)** |
  16. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`Basis<class_basis>` | :ref:`Basis<class_Basis_Basis>` **(** :ref:`Vector3<class_vector3>` x_axis, :ref:`Vector3<class_vector3>` y_axis, :ref:`Vector3<class_vector3>` z_axis **)** |
  18. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`float<class_float>` | :ref:`determinant<class_Basis_determinant>` **(** **)** |
  20. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Vector3<class_vector3>` | :ref:`get_euler<class_Basis_get_euler>` **(** **)** |
  22. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_orthogonal_index<class_Basis_get_orthogonal_index>` **(** **)** |
  24. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Vector3<class_vector3>` | :ref:`get_scale<class_Basis_get_scale>` **(** **)** |
  26. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Basis<class_basis>` | :ref:`inverse<class_Basis_inverse>` **(** **)** |
  28. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Basis<class_basis>` | :ref:`orthonormalized<class_Basis_orthonormalized>` **(** **)** |
  30. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Basis<class_basis>` | :ref:`rotated<class_Basis_rotated>` **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)** |
  32. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Basis<class_basis>` | :ref:`scaled<class_Basis_scaled>` **(** :ref:`Vector3<class_vector3>` scale **)** |
  34. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`tdotx<class_Basis_tdotx>` **(** :ref:`Vector3<class_vector3>` with **)** |
  36. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`tdoty<class_Basis_tdoty>` **(** :ref:`Vector3<class_vector3>` with **)** |
  38. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`float<class_float>` | :ref:`tdotz<class_Basis_tdotz>` **(** :ref:`Vector3<class_vector3>` with **)** |
  40. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Basis<class_basis>` | :ref:`transposed<class_Basis_transposed>` **(** **)** |
  42. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Vector3<class_vector3>` | :ref:`xform<class_Basis_xform>` **(** :ref:`Vector3<class_vector3>` v **)** |
  44. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Vector3<class_vector3>` | :ref:`xform_inv<class_Basis_xform_inv>` **(** :ref:`Vector3<class_vector3>` v **)** |
  46. +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. Member Variables
  48. ----------------
  49. - :ref:`Vector3<class_vector3>` **x**
  50. - :ref:`Vector3<class_vector3>` **y**
  51. - :ref:`Vector3<class_vector3>` **z**
  52. Description
  53. -----------
  54. 3x3 matrix used for 3D rotation and scale. Contains 3 vector fields x,y and z as its columns, which can be interpreted as the local basis vectors of a transformation. Can also be accessed as array of 3D vectors. These vectors are orthogonal to each other, but are not necessarily normalized. Almost always used as orthogonal basis for a :ref:`Transform<class_transform>`.
  55. For such use, it is composed of a scaling and a rotation matrix, in that order (M = R.S).
  56. Member Function Description
  57. ---------------------------
  58. .. _class_Basis_Basis:
  59. - :ref:`Basis<class_basis>` **Basis** **(** :ref:`Quat<class_quat>` from **)**
  60. Create a rotation matrix from the given quaternion.
  61. .. _class_Basis_Basis:
  62. - :ref:`Basis<class_basis>` **Basis** **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)**
  63. Create a rotation matrix which rotates around the given axis by the specified angle. The axis must be a normalized vector.
  64. .. _class_Basis_Basis:
  65. - :ref:`Basis<class_basis>` **Basis** **(** :ref:`Vector3<class_vector3>` x_axis, :ref:`Vector3<class_vector3>` y_axis, :ref:`Vector3<class_vector3>` z_axis **)**
  66. Create a matrix from 3 axis vectors.
  67. .. _class_Basis_determinant:
  68. - :ref:`float<class_float>` **determinant** **(** **)**
  69. Return the determinant of the matrix.
  70. .. _class_Basis_get_euler:
  71. - :ref:`Vector3<class_vector3>` **get_euler** **(** **)**
  72. Return Euler angles (in the XYZ convention: first Z, then Y, and X last) from the matrix. Returned vector contains the rotation angles in the format (third,second,first).
  73. This function only works if the matrix represents a proper rotation.
  74. .. _class_Basis_get_orthogonal_index:
  75. - :ref:`int<class_int>` **get_orthogonal_index** **(** **)**
  76. This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1,0 or 1, and returns the index of the point best representing the orientation of the object. It is mainly used by the grid map editor. For further details, refer to Godot source code.
  77. .. _class_Basis_get_scale:
  78. - :ref:`Vector3<class_vector3>` **get_scale** **(** **)**
  79. Assuming that the matrix is the combination of a rotation and scaling, return the absolute value of scaling factors along each axis.
  80. .. _class_Basis_inverse:
  81. - :ref:`Basis<class_basis>` **inverse** **(** **)**
  82. Return the inverse of the matrix.
  83. .. _class_Basis_orthonormalized:
  84. - :ref:`Basis<class_basis>` **orthonormalized** **(** **)**
  85. Return the orthonormalized version of the matrix (useful to call from time to time to avoid rounding error for orthogonal matrices). This performs a Gram-Schmidt orthonormalization on the basis of the matrix.
  86. .. _class_Basis_rotated:
  87. - :ref:`Basis<class_basis>` **rotated** **(** :ref:`Vector3<class_vector3>` axis, :ref:`float<class_float>` phi **)**
  88. Introduce an additional rotation around the given axis by phi. Only relevant when the matrix is being used as a part of :ref:`Transform<class_transform>`. The axis must be a normalized vector.
  89. .. _class_Basis_scaled:
  90. - :ref:`Basis<class_basis>` **scaled** **(** :ref:`Vector3<class_vector3>` scale **)**
  91. Introduce an additional scaling specified by the given 3D scaling factor. Only relevant when the matrix is being used as a part of :ref:`Transform<class_transform>`.
  92. .. _class_Basis_tdotx:
  93. - :ref:`float<class_float>` **tdotx** **(** :ref:`Vector3<class_vector3>` with **)**
  94. Transposed dot product with the x axis of the matrix.
  95. .. _class_Basis_tdoty:
  96. - :ref:`float<class_float>` **tdoty** **(** :ref:`Vector3<class_vector3>` with **)**
  97. Transposed dot product with the y axis of the matrix.
  98. .. _class_Basis_tdotz:
  99. - :ref:`float<class_float>` **tdotz** **(** :ref:`Vector3<class_vector3>` with **)**
  100. Transposed dot product with the z axis of the matrix.
  101. .. _class_Basis_transposed:
  102. - :ref:`Basis<class_basis>` **transposed** **(** **)**
  103. Return the transposed version of the matrix.
  104. .. _class_Basis_xform:
  105. - :ref:`Vector3<class_vector3>` **xform** **(** :ref:`Vector3<class_vector3>` v **)**
  106. Return a vector transformed (multiplied) by the matrix and return it.
  107. .. _class_Basis_xform_inv:
  108. - :ref:`Vector3<class_vector3>` **xform_inv** **(** :ref:`Vector3<class_vector3>` v **)**
  109. Return a vector transformed (multiplied) by the transposed matrix and return it. Note that this is a multiplication by inverse only when the matrix represents a rotation-reflection.