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