#import <ARVector3.h>
Inherits NSObject, <NSCoding>, and <NSCopying>.
Inherited by ARColour.
|
SEL | _vectorModifiedSelector |
|
__weak id | _delegate |
|
An ARVector3 is a 3-Dimensional vector consisting of an X, Y and Z component. Generally used to represent a point in 3D space.
◆ addVector:
Adds the components of two vectors together and returns the result.
Example of use:
ARVector3 vectorThree = [vectorOne addVector:vectorTwo];
- Parameters
-
vector | The vector to add to this vector. |
- Returns
- A new ARVector3 with values (X1 + X2, Y1 + Y2, Z1 + Z2).
◆ crossProductWithVector:
Calculates the cross product of this vector with the given vector and returns the result.
Example of use:
ARVector3 crossProductVector = [vectorOne crossProductWithVector:vectorTwo];
- Parameters
-
vector | The other vector to use for the cross product calculation. |
- Returns
- A new ARVector3 containing the cross product of the two vectors.
◆ distanceToVector:
- (float) distanceToVector: |
|
(ARVector3 *) |
vector |
|
Calculates the Euclidean distance between two 3-Dimensional points and returns the result.
Example of use:
float distance = [vectorOne distanceToVector:vectorTwo];
- Parameters
-
vector | The other vector to use for the distance calculation. |
- Returns
- The Euclidean distance between the two ARVector3 objects.
◆ divideByScalar:
- (ARVector3 *) divideByScalar: |
|
(double) |
scalar |
|
Divides each of this vector's components by a given value and returns the result.
Example of use:
ARVector3 newVector = [oldVector divideByScalar:2.0];
- Parameters
-
scalar | The value to divide this vector by. |
- Returns
- A new ARVector3 with values (X / scalar, Y / scalar, Z / scalar).
◆ divideByVector:
Divides this vector's components by the components of a given vector a returns the result.
Example of use:
ARVector3 vectorThree = [vectorOne divideByVector:vectorTwo];
- Parameters
-
vector | The vector to divide this vector by. |
- Returns
- A new ARVector3 with values (X1 / X2, Y1 / Y2, Z1 / Z2).
◆ dotProductWithVector:
- (float) dotProductWithVector: |
|
(ARVector3 *) |
vector |
|
Calculates the dot product of this vector and another given vector and returns the result.
Example of use:
float dotProduct = [vectorOne dotProductWithVector:vectorTwo];
- Parameters
-
vector | The other vector to use for the dot product calculation. |
- Returns
- The dot product of the two vectors, ((X1 * X2) + (Y1 * Y2) + (Z1 * Z2)).
◆ equalsVector:withTolerance:
- (BOOL) equalsVector: |
|
(ARVector3 *) |
vector |
withTolerance: |
|
(float) |
tolerance |
|
|
| |
Checks whether this vector is equal to another given vector. A tolerance value is used to account for potential floating-point errors.
Example of use:
BOOL isEqual = [vectorOne equalsVector:vectorTwo withTolerance:FLT_EPSILON];
- Parameters
-
vector | The vector to check against. |
tolerance | The maximum difference between each component of the vector. For example, if the tolerance were 0.1, then a vector with values (1.0, 1.0, 1.0) would be considered equal to a vector with values (1.0, 0.92, 1.099). The value FLT_EPSILON is a costant value of 0.00001, or 1e-5. |
- Returns
- True if each component of the two vectors are within the tolerance range, false otherwise.
◆ lerpTo:atTime:
Linearly interpolates between two vectors and returns the result. This is most commonly used to find a point some fraction of the way along a line between two endpoints (e.g. to move an object gradually between those points). With lerp, each step is equidistant. When time = 0 this vector is returned. When time = 1 the given vector is returned. When time = 0.5 a point midway between this vector and the given vector is returned. Values lower than 0 or above 1 will return a point outside the range of the two points along the same line.
Example of use:
ARVector3 lerpVector = [vectorOne lerpTo:vectorTwo atTime:0.5];
- Parameters
-
vector | The other vector to use for the interpolation calculation. |
time | Represents a percentage of how far along the line the resulting point should be. |
- Returns
- A new ARVector3 representing a point between this vector and the given vector.
◆ localAddVector:
Adds the components of two vectors together and stores the result in this vector.
Example of use:
[vectorOne localAddVector:vectorTwo];
- Parameters
-
vector | The vector to add to this vector. |
- Returns
- This vector with values (X1 + X2, Y1 + Y2, Z1 + Z2).
◆ localCrossProductWithVector:
Calculates the cross product of this vector with the given vector and store the result in this vector.
Example of use:
[vectorOne localCrossProductWithVector:vectorTwo];
- Parameters
-
vector | The other vector to use for the cross product calculation. |
- Returns
- This vector containing the cross product of the two vectors.
◆ localDivideByVector:
Divides this vector's components by the components of a given vector a stores the result in this vector.
Example of use:
[vectorOne divideByVector:vectorTwo];
- Parameters
-
vector | The vector to divide this vector by. |
- Returns
- This vector with values (X1 / X2, Y1 / Y2, Z1 / Z2).
◆ localMultiplyByVector:
Multiplies this vector's components by the components of a given vector and stores the result in this vector. This is NOT the same as the Dot Product OR the Cross Product. It simply multiplies the components together.
Example of use:
[vectorOne localMultiplyByVector:vectorTwo];
- Parameters
-
vector | The vector to multiply with this vector. |
- Returns
- This vector with values (X1 * X2, Y1 * Y2, Z1 * Z2).
◆ localSubtractVector:
Subtracts a given vector's components from the componentes this vector and stores the result in this vector.
Example of use:
[vectorOne subtractVector:vectorTwo];
- Parameters
-
vector | The vector to subtract from this vector. |
- Returns
- Thie vector with values (X1 - X2, Y1 - Y2, Z1 - Z2).
◆ multiplyByScalar:
- (ARVector3 *) multiplyByScalar: |
|
(double) |
scalar |
|
Multiplies each of this vector's components by a given value and returns the result.
Example of use:
ARVector3 newVector = [oldVector multiplyByScalar:4.0];
- Parameters
-
scalar | The value to multiply this vector by. |
- Returns
- A new ARVector3 with values (X * scalar, Y * scalar, Z * scalar).
◆ multiplyByVector:
Multiplies this vector's components by the components of a given vector and returns the result. This is NOT the same as the Dot Product OR the Cross Product. It simply multiplies the components together.
Example of use:
ARVector3 vectorThree = [vectorOne multiplyByVector:vectorTwo];
- Parameters
-
vector | The vector to multiply with this vector. |
- Returns
- A new ARVector3 with values (X1 * X2, Y1 * Y2, Z1 * Z2).
◆ negate
Normliases this vector so that each component of the vector is in the rang 0..1 and stores the result in this vector.
Example of use:
[vector localNormalise];
@return This vector containing the normalised vector.
/
- Returns
- A new ARVector3 containing the negated vector (-X, -Y, -Z).
◆ normalise
Normliases this vector so that each component of the vector is in the range 0..1 and returns the result. This is useful for finding the direction of a vector without its magnitude.
Example of use:
- Returns
- A new ARVector3 containing the normalised vector.
◆ rotationTo:
Calculates the quaternion rotation between this vector and the given vector and returns the result.
Example of use:
ARQuaternion rotationToVector = [vectorOne rotationTo:vectorTwo];
- Parameters
-
vector | The other vector to find the rotation to. |
- Returns
- A new ARQuaternion representing the rotation between this vector and the given vector.
◆ setModifyObserverWithDelegate:selector:
- (void) setModifyObserverWithDelegate: |
|
(id) |
delegate |
selector: |
|
(SEL) |
selector |
|
|
| |
Allows an ARNode to add an ARVector3 as an observer.
- Parameters
-
delegate | The delegate to assign to this vector. |
selector | The selector method to call when the vector is modified. |
◆ setX:y:z:
- (void) setX: |
|
(float) |
x |
y: |
|
(float) |
y |
z: |
|
(float) |
z |
|
|
| |
Sets the components of this vector with the given values.
Example of use:
[vector setX:1.0
y:2.0
z:3.0];
- Parameters
-
x | The value to give the X component of this vector. |
y | The value to give the Y component of this vector. |
z | The value to give the Z component of this vector. |
◆ subtractVector:
Subtracts a given vector's components from the components of this vector and returns the result.
Example of use:
ARVector3 vectorThree = [vectorOne subtractVector:vectorTwo];
- Parameters
-
vector | The vector to subtract from this vector. |
- Returns
- A new ARVector3 with values (X1 - X2, Y1 - Y2, Z1 - Z2).
◆ vectorWithValues:
Creates a new ARVector3 with the given value.
Example of use:
@float v The value to give all three components of the vector.
- Returns
- An ARVector3 with values (v, v, v);
◆ vectorWithValuesX:y:z:
+ (ARVector3 *) vectorWithValuesX: |
|
(float) |
x |
y: |
|
(float) |
y |
z: |
|
(float) |
z |
|
|
| |
Creates a new ARVector3 with the three given values.
Example of use:
- Parameters
-
x | The X component of the vector. |
y | The Y component of the vector. |
z | The Z component of the vector. |
- Returns
- An ARVector3 with values (x, y, z);
◆ vectorWithVector:
Creates a new ARVector3 with the given vector.
Example of use:
- Parameters
-
- Returns
- An ARVector3 with the same values as the given vector.
◆ vectorWithZero
◆ length
The length, or magnitude, of this vector, equal to sqrt((X * X) + (Y * Y) + (Z * Z)).
X component of the vector.
Y component of the vector.
Z component of the vector.
The documentation for this class was generated from the following files: