GLKVector3 Reference
The GLKVector3
type defines a 3
component floatingpoint 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.

Returns a new threecomponent vector created from individual component values.
Declaration
Swift
func GLKVector3Make(_
x
: Float, _y
: Float, _z
: Float) > GLKVector3ObjectiveC
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 threecomponent vector created from an array of components.
Declaration
Swift
func GLKVector3MakeWithArray(_
values
: UnsafeMutablePointer<Float>) > GLKVector3ObjectiveC
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) > FloatObjectiveC
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) > FloatObjectiveC
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 new vector created by negating the component values of another vector.
Declaration
Swift
func GLKVector3Negate(_
vector
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Negate ( GLKVector3 vector );
Parameters
vector
A vector.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns a new vector created by normalizing the input vector to a length of
1.0
.Declaration
Swift
func GLKVector3Normalize(_
vector
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Normalize ( GLKVector3 vector );
Parameters
vector
A vector.
Return Value
A new vector.
Discussion
The resulting vector points in the same direction as the input vector, but has a length of
1.0
.Availability
Available in iOS 5.0 and later.

Returns a new vector created by adding a scalar value to each component of a vector.
Declaration
Swift
func GLKVector3AddScalar(_
vector
: GLKVector3, _value
: Float) > GLKVector3ObjectiveC
GLKVector3 GLKVector3AddScalar ( GLKVector3 vector, float value );
Parameters
vector
A vector.
value
A scalar value.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns a new vector created by subtracting a scalar value from each component of a vector.
Declaration
Swift
func GLKVector3SubtractScalar(_
vector
: GLKVector3, _value
: Float) > GLKVector3ObjectiveC
GLKVector3 GLKVector3SubtractScalar ( GLKVector3 vector, float value );
Parameters
vector
A vector.
value
A scalar value.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns a new vector created by multiplying each component of a vector by a scalar value.
Declaration
Swift
func GLKVector3MultiplyScalar(_
vector
: GLKVector3, _value
: Float) > GLKVector3ObjectiveC
GLKVector3 GLKVector3MultiplyScalar ( GLKVector3 vector, float value );
Parameters
vector
A vector.
value
A scalar value.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns a new vector created by dividing each component of a vector by a scalar value.
Declaration
Swift
func GLKVector3DivideScalar(_
vector
: GLKVector3, _value
: Float) > GLKVector3ObjectiveC
GLKVector3 GLKVector3DivideScalar ( GLKVector3 vector, float value );
Parameters
vector
A vector.
value
A scalar value.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns the sum of two vectors.
Declaration
Swift
func GLKVector3Add(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Add ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
A new vector whose components each represent the sum of the two components found in the same positions of the two source vectors.
Availability
Available in iOS 5.0 and later.

Returns the difference between two vectors.
Declaration
Swift
func GLKVector3Subtract(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Subtract ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The starting vector.
vectorRight
The vector to subtract.
Return Value
A new vector whose components each represent the difference between the components found in the same positions of the two source vectors.
Availability
Available in iOS 5.0 and later.

Returns the product of two vectors.
Declaration
Swift
func GLKVector3Multiply(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Multiply ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
A new vector whose components each represent the product of the components found in the same positions of the two source vectors.
Availability
Available in iOS 5.0 and later.

Returns a new vector created by dividing one vector by another.
Declaration
Swift
func GLKVector3Divide(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Divide ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The dividend.
Return Value
A new vector whose components are each calculated by dividing the component found in same position of the first vector by the component found in the same position of the second vector.
Availability
Available in iOS 5.0 and later.

Returns the dot product of two vectors.
Declaration
Swift
func GLKVector3DotProduct(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > FloatObjectiveC
float GLKVector3DotProduct ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
The dot product of the two vectors.
Availability
Available in iOS 5.0 and later.

Returns the cross product of two vectors.
Declaration
Swift
func GLKVector3CrossProduct(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3CrossProduct ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns a new vector created by linearly interpreting between two vectors.
Declaration
Swift
func GLKVector3Lerp(_
vectorStart
: GLKVector3, _vectorEnd
: GLKVector3, _t
: Float) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Lerp ( GLKVector3 vectorStart, GLKVector3 vectorEnd, float t );
Parameters
vectorStart
The starting vector.
vectorEnd
The ending vector.
t
An interpolation constant.
Return Value
A new vector.
Discussion
The value of
t
should typically be between0.0
and1.0
. A value of0.0
returns the starting vector and a value of1.0
returns the ending vector. Any other value oft
results in a linear interpolation between the two points.Availability
Available in iOS 5.0 and later.

Returns a new vector created by projecting a vector onto another vector.
Declaration
Swift
func GLKVector3Project(_
vectorToProject
: GLKVector3, _projectionVector
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Project ( GLKVector3 vectorToProject, GLKVector3 projectionVector );
Parameters
vectorToProject
The vector being projected.
projectionVector
The projection vector.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns a new vector whose component value at each position is the largest component value at the same position in the source vectors.
Declaration
Swift
func GLKVector3Maximum(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Maximum ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
A new vector.
Availability
Available in iOS 5.0 and later.

Returns a new vector whose component value at each position is the smallest component value at the same position in the source vectors.
Declaration
Swift
func GLKVector3Minimum(_
vectorLeft
: GLKVector3, _vectorRight
: GLKVector3) > GLKVector3ObjectiveC
GLKVector3 GLKVector3Minimum ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
A new vector.
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) > BoolObjectiveC
bool GLKVector3AllEqualToScalar ( GLKVector3 vector, float value );
Parameters
vector
A vector.
value
A scalar.
Return Value
YES
true
if all of the vector’s components are equal tovalue
,NO
false
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) > BoolObjectiveC
bool GLKVector3AllEqualToVector3 ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
YES
true
if all of the vectors’ components are equal ,NO
false
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) > BoolObjectiveC
bool GLKVector3AllGreaterThanOrEqualToScalar ( GLKVector3 vector, float value );
Parameters
vector
A vector.
value
A scalar.
Return Value
YES
true
if all of the vector’s components are greater than or equal to the scalar value,NO
false
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) > BoolObjectiveC
bool GLKVector3AllGreaterThanOrEqualToVector3 ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
YES
true
if each component in the first vector is greater than or equal to the corresponding component of the second vector,NO
false
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) > BoolObjectiveC
bool GLKVector3AllGreaterThanScalar ( GLKVector3 vector, float value );
Parameters
vector
A vector.
value
A scalar.
Return Value
YES
true
if all of the vector’s components are greater than the scalar value,NO
false
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) > BoolObjectiveC
bool GLKVector3AllGreaterThanVector3 ( GLKVector3 vectorLeft, GLKVector3 vectorRight );
Parameters
vectorLeft
The first vector.
vectorRight
The second vector.
Return Value
YES
true
if each component in the first vector is greater than the corresponding component of the second vector,NO
false
otherwise.Availability
Available in iOS 5.0 and later.

A representation of a 3component vector.
Declaration
Swift
typealias GLKVector3 = _GLKVector3
ObjectiveC
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.
Copyright © 2016 Apple Inc. All rights reserved. Terms of Use  Privacy Policy  Updated: 20120717