set.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. return {
  2. summary = 'Set the components of the quaternion.',
  3. description = [[
  4. Sets the components of the quaternion. There are lots of different ways to specify the new
  5. components, the summary is:
  6. - Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions.
  7. - Four numbers plus the fifth `raw` flag can be used to set the raw values of the quaternion.
  8. - An existing quaternion can be passed in to copy its values.
  9. - A single direction vector can be specified to turn its direction (relative to the default
  10. forward direction of "negative z") into a rotation.
  11. - Two direction vectors can be specified to set the quaternion equal to the rotation between the
  12. two vectors.
  13. - A matrix can be passed in to extract the rotation of the matrix into a quaternion.
  14. ]],
  15. arguments = {
  16. angle = {
  17. default = '0',
  18. description = 'The angle to use for the rotation, in radians.'
  19. },
  20. ax = {
  21. type = 'number',
  22. default = '0',
  23. description = 'The x component of the axis of rotation.'
  24. },
  25. ay = {
  26. type = 'number',
  27. default = '0',
  28. description = 'The y component of the axis of rotation.'
  29. },
  30. az = {
  31. type = 'number',
  32. default = '0',
  33. description = 'The z component of the axis of rotation.'
  34. },
  35. raw = {
  36. type = 'boolean',
  37. default = 'false',
  38. description = 'Whether the components should be interpreted as raw `(x, y, z, w)` components.'
  39. },
  40. v = {
  41. type = 'vec3',
  42. description = 'A normalized direction vector.'
  43. },
  44. u = {
  45. type = 'vec3',
  46. description = 'Another normalized direction vector.'
  47. },
  48. r = {
  49. type = 'quat',
  50. description = 'An existing quaternion to copy the values from.'
  51. },
  52. m = {
  53. type = 'mat4',
  54. description = 'A matrix to use the rotation from.'
  55. }
  56. },
  57. returns = {
  58. q = {
  59. type = 'quat',
  60. description = 'The original quaternion.'
  61. }
  62. },
  63. variants = {
  64. {
  65. arguments = { 'angle', 'ax', 'ay', 'az', 'raw' },
  66. returns = { 'q' }
  67. },
  68. {
  69. arguments = { 'r' },
  70. returns = { 'q' }
  71. },
  72. {
  73. description = 'Sets the values from a direction vector.',
  74. arguments = { 'v' },
  75. returns = { 'q' }
  76. },
  77. {
  78. description = 'Sets the values to represent the rotation between two vectors.',
  79. arguments = { 'v', 'u' },
  80. returns = { 'q' }
  81. },
  82. {
  83. arguments = { 'm' },
  84. returns = { 'q' }
  85. },
  86. {
  87. description = 'Reset the quaternion to the identity (0, 0, 0, 1).',
  88. arguments = {},
  89. returns = { 'q' }
  90. }
  91. },
  92. related = {
  93. 'Quat:unpack'
  94. }
  95. }