iOS Developer Library — Prerelease

Developer

GLKit Framework Reference GLKVector3 Reference

Options
Deployment Target:

On This Page
Language:

GLKVector3 Reference

The GLKVector3 type defines a 3-component floating-point vector as well as many mathematical operations commonly used to manipulate vectors. Graphics programming uses vectors extensively to represent positions, normals, colors and other data structures.

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

Functions

  • Returns a new three-component vector created from individual component values.

    Declaration

    Swift

    func GLKVector3Make(_ x: Float, _ y: Float, _ z: Float) -> GLKVector3

    Objective-C

    GLKVector3 GLKVector3Make ( float x, float y, float z );

    Parameters

    x

    The first component.

    y

    The second component.

    z

    The third component.

    Return Value

    An initialized vector.

    Availability

    Available in iOS 5.0 and later.

  • Returns a new three-component vector created from an array of components.

    Declaration

    Swift

    func GLKVector3MakeWithArray(_ values: UnsafeMutablePointer<Float>) -> GLKVector3

    Objective-C

    GLKVector3 GLKVector3MakeWithArray ( float values[3] );

    Parameters

    values

    The array containing the component values.

    Return Value

    The array.

    Discussion

    An initialized vector.

    Availability

    Available in iOS 5.0 and later.

  • Returns the length of a vector.

    Declaration

    Swift

    func GLKVector3Length(_ vector: GLKVector3) -> Float

    Objective-C

    float GLKVector3Length ( GLKVector3 vector );

    Parameters

    vector

    A vector.

    Return Value

    The length of the vector.

    Availability

    Available in iOS 5.0 and later.

  • Returns the distance between two points.

    Declaration

    Swift

    func GLKVector3Distance(_ vectorStart: GLKVector3, _ vectorEnd: GLKVector3) -> Float

    Objective-C

    float GLKVector3Distance ( GLKVector3 vectorStart, GLKVector3 vectorEnd );

    Parameters

    vectorStart

    A vector providing the coordinates of the starting point.

    vectorEnd

    A vector providing the coordinates of the ending point.

    Return Value

    The distance between the two points.

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value that states whether all the components of the source vector are equal to a scalar value.

    Declaration

    Swift

    func GLKVector3AllEqualToScalar(_ vector: GLKVector3, _ value: Float) -> Bool

    Objective-C

    bool GLKVector3AllEqualToScalar ( GLKVector3 vector, float value );

    Parameters

    vector

    A vector.

    value

    A scalar.

    Return Value

    YEStrue if all of the vector’s components are equal to value, NOfalse otherwise.

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value that indicates whether each component of the first vector is equal to the corresponding component of a second vector.

    Declaration

    Swift

    func GLKVector3AllEqualToVector3(_ vectorLeft: GLKVector3, _ vectorRight: GLKVector3) -> Bool

    Objective-C

    bool GLKVector3AllEqualToVector3 ( GLKVector3 vectorLeft, GLKVector3 vectorRight );

    Parameters

    vectorLeft

    The first vector.

    vectorRight

    The second vector.

    Return Value

    YEStrue if all of the vectors’ components are equal , NOfalse otherwise.

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value that states whether all the components of the source vector are greater than or equal to a scalar value.

    Declaration

    Swift

    func GLKVector3AllGreaterThanOrEqualToScalar(_ vector: GLKVector3, _ value: Float) -> Bool

    Objective-C

    bool GLKVector3AllGreaterThanOrEqualToScalar ( GLKVector3 vector, float value );

    Parameters

    vector

    A vector.

    value

    A scalar.

    Return Value

    YEStrue if all of the vector’s components are greater than or equal to the scalar value, NOfalse otherwise.

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value that indicates whether each component of the first vector is greater than or equal to the corresponding component of a second vector.

    Declaration

    Swift

    func GLKVector3AllGreaterThanOrEqualToVector3(_ vectorLeft: GLKVector3, _ vectorRight: GLKVector3) -> Bool

    Objective-C

    bool GLKVector3AllGreaterThanOrEqualToVector3 ( GLKVector3 vectorLeft, GLKVector3 vectorRight );

    Parameters

    vectorLeft

    The first vector.

    vectorRight

    The second vector.

    Return Value

    YEStrue if each component in the first vector is greater than or equal to the corresponding component of the second vector, NOfalse otherwise.

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value that states whether all the components of the source vector are greater than a scalar value.

    Declaration

    Swift

    func GLKVector3AllGreaterThanScalar(_ vector: GLKVector3, _ value: Float) -> Bool

    Objective-C

    bool GLKVector3AllGreaterThanScalar ( GLKVector3 vector, float value );

    Parameters

    vector

    A vector.

    value

    A scalar.

    Return Value

    YEStrue if all of the vector’s components are greater than the scalar value, NOfalse otherwise.

    Availability

    Available in iOS 5.0 and later.

  • Returns a Boolean value that indicates whether each component of the first vector is greater than the corresponding component of a second vector.

    Declaration

    Swift

    func GLKVector3AllGreaterThanVector3(_ vectorLeft: GLKVector3, _ vectorRight: GLKVector3) -> Bool

    Objective-C

    bool GLKVector3AllGreaterThanVector3 ( GLKVector3 vectorLeft, GLKVector3 vectorRight );

    Parameters

    vectorLeft

    The first vector.

    vectorRight

    The second vector.

    Return Value

    YEStrue if each component in the first vector is greater than the corresponding component of the second vector, NOfalse otherwise.

    Availability

    Available in iOS 5.0 and later.

Data Types

  • A representation of a 3-component vector.

    Declaration

    Swift

    typealias GLKVector3 = _GLKVector3

    Objective-C

    union _GLKVector3 { struct { float x, y, z; }; struct { float r, g, b; }; struct { float s, t, p; }; float v[3]; }; typedef union _GLKVector3 GLKVector3;

    Fields

    x

    The first component in the vector. Typically used when the vector refers to a position or a normal.

    y

    The second component in the vector. Typically used when the vector refers to a position or a normal.

    z

    The third component in the vector. Typically used when the vector refers to a position or a normal.

    r

    The first component in the vector. Typically used when the vector refers to a color value.

    g

    The second component in the vector. Typically used when the vector refers to a color value.

    b

    The third component in the vector. Typically used when the vector refers to a color value.

    s

    The first component in the vector. Typically used when the vector refers to texture coordinates.

    t

    The second component in the vector. Typically used when the vector refers to texture coordinates.

    p

    The third component in the vector. Typically used when the vector refers to texture coordinates.

    v

    The elements of the vector expressed as an array.

    Availability

    Available in iOS 5.0 and later.