<!--
{
  "documentType" : "article",
  "framework" : "GLKit",
  "identifier" : "/documentation/GLKit/glkvector2-pbj",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "GLKVector2"
}
-->

# GLKVector2

## Overview

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.

## Topics

### Creating Vectors

[`func GLKVector2Make(Float, Float) -> GLKVector2`](/documentation/GLKit/GLKVector2Make(_:_:))

Returns a new two-component vector created from individual component values.

[`func GLKVector2MakeWithArray(UnsafeMutablePointer<Float>!) -> GLKVector2`](/documentation/GLKit/GLKVector2MakeWithArray(_:))

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

### Retrieving Information About a Vector

[`func GLKVector2Length(GLKVector2) -> Float`](/documentation/GLKit/GLKVector2Length(_:))

Returns the length of a vector.

[`func GLKVector2Distance(GLKVector2, GLKVector2) -> Float`](/documentation/GLKit/GLKVector2Distance(_:_:))

Returns the distance between two points.

### Mathematical Operations Performed on Vectors

[`func GLKVector2Negate(GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Negate(_:))

Returns a new vector created by negating the component values of another vector.

[`func GLKVector2Normalize(GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Normalize(_:))

Returns a new vector created by normalizing an input vector to a length of `1.0`.

[`func GLKVector2AddScalar(GLKVector2, Float) -> GLKVector2`](/documentation/GLKit/GLKVector2AddScalar(_:_:))

Returns a new vector created by adding a scalar value to each component of a vector.

[`func GLKVector2SubtractScalar(GLKVector2, Float) -> GLKVector2`](/documentation/GLKit/GLKVector2SubtractScalar(_:_:))

Returns a new vector created by subtracting a scalar value from each component of a vector.

[`func GLKVector2MultiplyScalar(GLKVector2, Float) -> GLKVector2`](/documentation/GLKit/GLKVector2MultiplyScalar(_:_:))

Returns a new vector created by multiplying each component of a vector by a scalar value.

[`func GLKVector2DivideScalar(GLKVector2, Float) -> GLKVector2`](/documentation/GLKit/GLKVector2DivideScalar(_:_:))

Returns a new vector created by dividing each component of a vector by a scalar value.

[`func GLKVector2Add(GLKVector2, GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Add(_:_:))

Returns the sum of two vectors.

[`func GLKVector2Subtract(GLKVector2, GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Subtract(_:_:))

Returns the difference between two vectors.

[`func GLKVector2Multiply(GLKVector2, GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Multiply(_:_:))

Returns a new vector created by multiplying one vector by another.

[`func GLKVector2Divide(GLKVector2, GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Divide(_:_:))

Returns a new vector created by dividing one vector by another.

[`func GLKVector2DotProduct(GLKVector2, GLKVector2) -> Float`](/documentation/GLKit/GLKVector2DotProduct(_:_:))

Returns the dot product of two vectors.

[`func GLKVector2Lerp(GLKVector2, GLKVector2, Float) -> GLKVector2`](/documentation/GLKit/GLKVector2Lerp(_:_:_:))

Returns a new vector created by linearly interpreting between two vectors.

[`func GLKVector2Project(GLKVector2, GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Project(_:_:))

Returns a new vector created by projecting a vector onto another vector

[`func GLKVector2Maximum(GLKVector2, GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Maximum(_:_:))

Returns a new vector whose component value at each position is the largest component value at the same position of the two source vectors.

[`func GLKVector2Minimum(GLKVector2, GLKVector2) -> GLKVector2`](/documentation/GLKit/GLKVector2Minimum(_:_:))

Returns a new vector whose component value at each position is the smallest component value at the same position of the two source vectors.

### Comparison Operations

[`func GLKVector2AllEqualToScalar(GLKVector2, Float) -> Bool`](/documentation/GLKit/GLKVector2AllEqualToScalar(_:_:))

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

[`func GLKVector2AllEqualToVector2(GLKVector2, GLKVector2) -> Bool`](/documentation/GLKit/GLKVector2AllEqualToVector2(_:_:))

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

[`func GLKVector2AllGreaterThanOrEqualToScalar(GLKVector2, Float) -> Bool`](/documentation/GLKit/GLKVector2AllGreaterThanOrEqualToScalar(_:_:))

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

[`func GLKVector2AllGreaterThanOrEqualToVector2(GLKVector2, GLKVector2) -> Bool`](/documentation/GLKit/GLKVector2AllGreaterThanOrEqualToVector2(_:_:))

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.

[`func GLKVector2AllGreaterThanScalar(GLKVector2, Float) -> Bool`](/documentation/GLKit/GLKVector2AllGreaterThanScalar(_:_:))

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

[`func GLKVector2AllGreaterThanVector2(GLKVector2, GLKVector2) -> Bool`](/documentation/GLKit/GLKVector2AllGreaterThanVector2(_:_:))

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

### Data Types

[`typealias GLKVector2`](/documentation/GLKit/GLKVector2)

A representation of a 2-component vector.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)