quaternion.proto 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.type;
  16. option cc_enable_arenas = true;
  17. option go_package = "google.golang.org/genproto/googleapis/type/quaternion;quaternion";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "QuaternionProto";
  20. option java_package = "com.google.type";
  21. option objc_class_prefix = "GTP";
  22. // A quaternion is defined as the quotient of two directed lines in a
  23. // three-dimensional space or equivalently as the quotient of two Euclidean
  24. // vectors (https://en.wikipedia.org/wiki/Quaternion).
  25. //
  26. // Quaternions are often used in calculations involving three-dimensional
  27. // rotations (https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation),
  28. // as they provide greater mathematical robustness by avoiding the gimbal lock
  29. // problems that can be encountered when using Euler angles
  30. // (https://en.wikipedia.org/wiki/Gimbal_lock).
  31. //
  32. // Quaternions are generally represented in this form:
  33. //
  34. // w + xi + yj + zk
  35. //
  36. // where x, y, z, and w are real numbers, and i, j, and k are three imaginary
  37. // numbers.
  38. //
  39. // Our naming choice `(x, y, z, w)` comes from the desire to avoid confusion for
  40. // those interested in the geometric properties of the quaternion in the 3D
  41. // Cartesian space. Other texts often use alternative names or subscripts, such
  42. // as `(a, b, c, d)`, `(1, i, j, k)`, or `(0, 1, 2, 3)`, which are perhaps
  43. // better suited for mathematical interpretations.
  44. //
  45. // To avoid any confusion, as well as to maintain compatibility with a large
  46. // number of software libraries, the quaternions represented using the protocol
  47. // buffer below *must* follow the Hamilton convention, which defines `ij = k`
  48. // (i.e. a right-handed algebra), and therefore:
  49. //
  50. // i^2 = j^2 = k^2 = ijk = −1
  51. // ij = −ji = k
  52. // jk = −kj = i
  53. // ki = −ik = j
  54. //
  55. // Please DO NOT use this to represent quaternions that follow the JPL
  56. // convention, or any of the other quaternion flavors out there.
  57. //
  58. // Definitions:
  59. //
  60. // - Quaternion norm (or magnitude): `sqrt(x^2 + y^2 + z^2 + w^2)`.
  61. // - Unit (or normalized) quaternion: a quaternion whose norm is 1.
  62. // - Pure quaternion: a quaternion whose scalar component (`w`) is 0.
  63. // - Rotation quaternion: a unit quaternion used to represent rotation.
  64. // - Orientation quaternion: a unit quaternion used to represent orientation.
  65. //
  66. // A quaternion can be normalized by dividing it by its norm. The resulting
  67. // quaternion maintains the same direction, but has a norm of 1, i.e. it moves
  68. // on the unit sphere. This is generally necessary for rotation and orientation
  69. // quaternions, to avoid rounding errors:
  70. // https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions
  71. //
  72. // Note that `(x, y, z, w)` and `(-x, -y, -z, -w)` represent the same rotation,
  73. // but normalization would be even more useful, e.g. for comparison purposes, if
  74. // it would produce a unique representation. It is thus recommended that `w` be
  75. // kept positive, which can be achieved by changing all the signs when `w` is
  76. // negative.
  77. //
  78. message Quaternion {
  79. // The x component.
  80. double x = 1;
  81. // The y component.
  82. double y = 2;
  83. // The z component.
  84. double z = 3;
  85. // The scalar component.
  86. double w = 4;
  87. }