warp.quaternion =============== .. currentmodule:: warp._src.lang .. function:: quaternion(dtype: Float = ...) -> Quaternion[Float] .. wp-function-tags:: :kernel: true :python: false :differentiable: true Construct a zero-initialized quaternion. Quaternions store their components in ``(x, y, z, w)`` order, where ``x``, ``y``, and ``z`` form the vector (imaginary) part and ``w`` is the scalar (real) part. For the identity rotation, use :func:`~warp.quat_identity`. :param dtype: Scalar type of the components. Defaults to ``float32``. :returns: The quaternion ``(0, 0, 0, 0)``. .. function:: quaternion(x: Float, y: Float, z: Float, w: Float, dtype: Float = ...) -> Quaternion[Float] :noindex: .. wp-function-tags:: :kernel: true :python: false :differentiable: true Construct a quaternion from its components. All arguments must have the same scalar type, which must match ``dtype`` when it is given. :param x: ``x`` component of the vector (imaginary) part. :param y: ``y`` component of the vector (imaginary) part. :param z: ``z`` component of the vector (imaginary) part. :param w: Scalar (real) part. :param dtype: Scalar type of the components, inferred from the other arguments when omitted. :returns: The quaternion ``(x, y, z, w)``. .. function:: quaternion(ijk: Vector[Float, Literal[3]], real: Float, dtype: Float = ...) -> Quaternion[Float] :noindex: .. wp-function-tags:: :kernel: true :python: false :differentiable: true Construct a quaternion from its vector and scalar parts. All arguments must have the same scalar type, which must match ``dtype`` when it is given. :param ijk: Vector (imaginary) part, stored as the ``x``, ``y``, and ``z`` components. :param real: Scalar (real) part, stored as the ``w`` component. :param dtype: Scalar type of the components, inferred from the other arguments when omitted. :returns: The quaternion ``(ijk[0], ijk[1], ijk[2], real)``. .. function:: quaternion(quat: Quaternion[Float], dtype: Float = ...) -> Quaternion[Float] :noindex: .. wp-function-tags:: :kernel: true :python: false :differentiable: true Construct a copy of a quaternion, optionally converting its scalar type. :param quat: Quaternion to copy. :param dtype: Scalar type of the result. Defaults to the scalar type of ``quat``. :returns: A quaternion with the components of ``quat``, converted to ``dtype``.