iOS Developer Library — Prerelease

Developer

GLKit Framework Reference GLKVector2 Reference

Options
Deployment Target:

On This Page
Language:

GLKVector2 Reference

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

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

Functions

  • Returns the length of a vector.

    Declaration

    Swift

    func GLKVector2Length(_ vector: GLKVector2) -> Float

    Objective-C

    float GLKVector2Length ( GLKVector2 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 GLKVector2Distance(_ vectorStart: GLKVector2, _ vectorEnd: GLKVector2) -> Float

    Objective-C

    float GLKVector2Distance ( GLKVector2 vectorStart, GLKVector2 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 GLKVector2AllEqualToScalar(_ vector: GLKVector2, _ value: Float) -> Bool

    Objective-C

    bool GLKVector2AllEqualToScalar ( GLKVector2 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 GLKVector2AllEqualToVector2(_ vectorLeft: GLKVector2, _ vectorRight: GLKVector2) -> Bool

    Objective-C

    bool GLKVector2AllEqualToVector2 ( GLKVector2 vectorLeft, GLKVector2 vectorRight );

    Parameters

    vectorLeft

    The first vector.

    vectorRight

    The second vector.

    Return Value

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

    Discussion

    The vectors are considered equal when the value for the component at each position in the two source vectors is equal.

    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 GLKVector2AllGreaterThanOrEqualToScalar(_ vector: GLKVector2, _ value: Float) -> Bool

    Objective-C

    bool GLKVector2AllGreaterThanOrEqualToScalar ( GLKVector2 vector, float value );

    Parameters

    vector

    A vector.

    value

    A scalar.

    Return Value

    A Boolean value that states whether the vector components are all greater than or equal to the scalar value.

    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 GLKVector2AllGreaterThanOrEqualToVector2(_ vectorLeft: GLKVector2, _ vectorRight: GLKVector2) -> Bool

    Objective-C

    bool GLKVector2AllGreaterThanOrEqualToVector2 ( GLKVector2 vectorLeft, GLKVector2 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 GLKVector2AllGreaterThanScalar(_ vector: GLKVector2, _ value: Float) -> Bool

    Objective-C

    bool GLKVector2AllGreaterThanScalar ( GLKVector2 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 GLKVector2AllGreaterThanVector2(_ vectorLeft: GLKVector2, _ vectorRight: GLKVector2) -> Bool

    Objective-C

    bool GLKVector2AllGreaterThanVector2 ( GLKVector2 vectorLeft, GLKVector2 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 2-component vector.

    Declaration

    Swift

    typealias GLKVector2 = _GLKVector2

    Objective-C

    union _GLKVector2 { struct { float x, y; }; struct { float s, t; }; float v[2]; }; typedef union _GLKVector2 GLKVector2;

    Fields

    x

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

    y

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

    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.

    v

    The elements of the vector expressed as an array.

    Availability

    Available in iOS 5.0 and later.