iOS Developer Library — Pre-Release

Developer

GLKit Framework Reference GLKQuaternion Reference

Options
Deployment Target:

On This Page
Language:

GLKQuaternion Reference

The GLKQuaternion type defines a structure that represents a quaternion. A quaternion is defined by a scalar component s and an XYZ vector v. Quaternions are often used in graphics programming as a compact representation of a rotation of an object in three dimensions.

The functions that manipulate GLKQuaternion structures treat the inputs as immutable, instead returning a new quaternion that represent the results of the operation.

Functions

  • Returns a quaternion created from its separate components.

    Declaration

    Swift

    func GLKQuaternionMake(_ x: Float, _ y: Float, _ z: Float, _ w: Float) -> GLKQuaternion

    Objective-C

    GLKQuaternion GLKQuaternionMake ( float x, float y, float z, float w );

    Parameters

    x

    The x component of the quaternion.

    y

    The y component of the quaternion.

    z

    The z component of the quaternion.

    w

    The w component of the quaternion.

    Return Value

    A new quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a quaternion created from an array of components.

    Declaration

    Swift

    func GLKQuaternionMakeWithArray(_ float values[4]: UnsafeMutablePointer<Float>) -> GLKQuaternion

    Objective-C

    GLKQuaternion GLKQuaternionMakeWithArray ( float values[4] );

    Parameters

    float values[4]

    The four components that comprise the new quaternion.

    Return Value

    A new quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Returns a quaternion created from a vector and a scalar.

    Declaration

    Swift

    func GLKQuaternionMakeWithVector3(_ vector: GLKVector3, _ scalar: Float) -> GLKQuaternion

    Objective-C

    GLKQuaternion GLKQuaternionMakeWithVector3 ( GLKVector3 vector, float scalar );

    Parameters

    vector

    The vector portion of the new quaternion.

    scalar

    The scalar portion of the new quaternion.

    Return Value

    A new quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Creates a quaternion that represents a rotation around an axis.

    Declaration

    Swift

    func GLKQuaternionMakeWithAngleAndAxis(_ radians: Float, _ x: Float, _ y: Float, _ z: Float) -> GLKQuaternion

    Objective-C

    GLKQuaternion GLKQuaternionMakeWithAngleAndAxis ( float radians, float x, float y, float z );

    Parameters

    radians

    The angle of the rotation in radians (a positive angle is counterclockwise).

    x

    The x component of the axis.

    y

    The y component of the axis.

    z

    The z component of the axis.

    Return Value

    A new quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Creates a quaternion that represents a rotation around an axis.

    Declaration

    Swift

    func GLKQuaternionMakeWithAngleAndVector3Axis(_ radians: Float, _ axisVector: GLKVector3) -> GLKQuaternion

    Objective-C

    GLKQuaternion GLKQuaternionMakeWithAngleAndVector3Axis ( float radians, GLKVector3 axisVector );

    Parameters

    radians

    The angle of the rotation in radians (a positive angle is counterclockwise).

    axisVector

    The axis of rotation.

    Return Value

    A new quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Creates a quaternion from a rotation matrix.

    Declaration

    Swift

    func GLKQuaternionMakeWithMatrix3(_ matrix: GLKMatrix3) -> GLKQuaternion

    Objective-C

    GLKQuaternion GLKQuaternionMakeWithMatrix3 ( GLKMatrix3 matrix );

    Parameters

    matrix

    A rotation matrix to convert into a quaternion.

    Return Value

    A new quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Creates a quaternion from a rotation matrix.

    Declaration

    Swift

    func GLKQuaternionMakeWithMatrix4(_ matrix: GLKMatrix4) -> GLKQuaternion

    Objective-C

    GLKQuaternion GLKQuaternionMakeWithMatrix4 ( GLKMatrix4 matrix );

    Parameters

    matrix

    A rotation matrix to convert into a quaternion.

    Return Value

    A new quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Returns the length of a quaternion.

    Declaration

    Swift

    func GLKQuaternionLength(_ quaternion: GLKQuaternion) -> Float

    Objective-C

    float GLKQuaternionLength ( GLKQuaternion quaternion );

    Parameters

    quaternion

    A quaternion.

    Return Value

    The length of the quaternion.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Returns the axis of rotation of a quaternion.

    Declaration

    Swift

    func GLKQuaternionAxis(_ quaternion: GLKQuaternion) -> GLKVector3

    Objective-C

    GLKVector3 GLKQuaternionAxis ( GLKQuaternion quaternion );

    Parameters

    quaternion

    A quaternion.

    Return Value

    The axis of rotation.

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

  • Returns the rotation angle of a quaternion.

    Declaration

    Swift

    func GLKQuaternionAngle(_ quaternion: GLKQuaternion) -> Float

    Objective-C

    float GLKQuaternionAngle ( GLKQuaternion quaternion );

    Parameters

    quaternion

    A quaternion.

    Return Value

    The angle of the rotation in radians (a positive angle is counterclockwise).

    Import Statement

    Objective-C

    @import GLKit;

    Swift

    import GLKit

    Availability

    Available in iOS 5.0 and later.

Data Types

  • A representation of a quaternion.

    Declaration

    Swift

    typealias GLKQuaternion = _GLKQuaternion

    Objective-C

    union _GLKQuaternion { struct { GLKVector3 v; float s; }; struct { float x, y, z, w; }; float q[4]; } typedef union _GLKQuaternion GLKQuaternion;

    Fields

    v

    The vector portion of the quaternion.

    s

    The scalar component of the quaternion.

    x

    The x component of the vector portion of the quaternion.

    y

    The y component of the vector portion of the quaternion.

    z

    The z component of the vector portion of the quaternion.

    w

    The scalar component of the quaternion.

    q

    The components of the quaternion expressed as an array of elements.

    Availability

    Available in iOS 5.0 and later.

Constants

  • An identity quaternion.

    Declaration

    Swift

    let GLKQuaternionIdentity: GLKQuaternion

    Objective-C

    extern const GLKQuaternion GLKQuaternionIdentity;

    Constants

    • GLKQuaternionIdentity

      GLKQuaternionIdentity

      An identity quaternion.

      Available in iOS 5.0 and later.