Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Quaternion

struct in UnityEngine

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual

Descripción

Los cuaterniones se usan para representar rotaciones.

They are compact, don't suffer from gimbal lock and can easily be interpolated. Unity internally uses Quaternions to represent all rotations.

They are based on complex numbers and are not easy to understand intuitively. You almost never access or modify individual Quaternion components (x,y,z,w); most often you would just take existing rotations (e.g. from the Transform) and use them to construct new rotations (e.g. to smoothly interpolate between two rotations). The Quaternion functions that you use 99% of the time are: Quaternion.LookRotation, Quaternion.Angle, Quaternion.Euler, Quaternion.Slerp, Quaternion.FromToRotation, and Quaternion.identity. (The other functions are only for exotic uses.)

You can use the Quaternion.operator * to rotate one rotation by another, or to rotate a vector by a rotation.

Variables Estáticas

identityThe identity rotation (Read Only).

Variables

eulerAnglesReturns the euler angle representation of the rotation.
this[int]Access the x, y, z, w components using [0], [1], [2], [3] respectively.
wW component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
xX component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
yY component of the Quaternion. Don't modify this directly unless you know quaternions inside out.
zZ component of the Quaternion. Don't modify this directly unless you know quaternions inside out.

Constructores

QuaternionConstructs new Quaternion with given x,y,z,w components.

Funciones Públicas

SetSet x, y, z and w components of an existing Quaternion.
SetFromToRotationCreates a rotation which rotates from fromDirection to toDirection.
SetLookRotationCreates a rotation with the specified forward and upwards directions.
ToAngleAxisConverts a rotation to angle-axis representation (angles in degrees).
ToStringReturns a nicely formatted string of the Quaternion.

Funciones Estáticas

AngleReturns the angle in degrees between two rotations a and b.
AngleAxisCreates a rotation which rotates angle degrees around axis.
DotEl producto escalar entre dos rotaciones.
EulerReturns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).
FromToRotationCreates a rotation which rotates from fromDirection to toDirection.
InverseReturns the Inverse of rotation.
LerpInterpolates between a and b by t and normalizes the result afterwards. The parameter t is clamped to the range [0, 1].
LerpUnclampedInterpolates between a and b by t and normalizes the result afterwards. The parameter t is not clamped.
LookRotationCreates a rotation with the specified forward and upwards directions.
RotateTowardsRotates a rotation from towards to.
SlerpSpherically interpolates between a and b by t. The parameter t is clamped to the range [0, 1].
SlerpUnclampedSpherically interpolates between a and b by t. The parameter t is not clamped.

Operadores

operator !=Are two quaternions different from each other?
operator *Take the rotation state of lhs and apply a rotation of rhs.
operator ==Are two quaternions equal to each other?