KudanAR - iOS  1.6.0
ARVector3 Class Reference

#import <ARVector3.h>

Inherits NSObject, <NSCoding>, and <NSCopying>.

Inherited by ARColour.

Instance Methods

(BOOL) - equalsVector:withTolerance:
 
(ARVector3 *) - addVector:
 
(ARVector3 *) - localAddVector:
 
(ARVector3 *) - subtractVector:
 
(ARVector3 *) - localSubtractVector:
 
(ARVector3 *) - multiplyByVector:
 
(ARVector3 *) - localMultiplyByVector:
 
(ARVector3 *) - divideByVector:
 
(ARVector3 *) - localDivideByVector:
 
(ARVector3 *) - multiplyByScalar:
 
(ARVector3 *) - divideByScalar:
 
(float) - distanceToVector:
 
(float) - dotProductWithVector:
 
(ARVector3 *) - normalise
 
(ARVector3 *) - negate
 
(ARVector3 *) - crossProductWithVector:
 
(ARVector3 *) - localCrossProductWithVector:
 
(ARQuaternion *) - rotationTo:
 
(ARVector3 *) - lerpTo:atTime:
 
(void) - setX:y:z:
 
(void) - setModifyObserverWithDelegate:selector:
 

Class Methods

(ARVector3 *) + vectorWithZero
 
(ARVector3 *) + vectorWithValuesX:y:z:
 
(ARVector3 *) + vectorWithValues:
 
(ARVector3 *) + vectorWithVector:
 
(ARVector3 *) + vectorWithOML: [implementation]
 

Protected Attributes

SEL _vectorModifiedSelector
 
__weak id _delegate
 

Properties

float x
 
float y
 
float z
 
float length
 
OgreMathLib::Vector3 vectorOML [implementation]
 

Detailed Description

An ARVector3 is a 3-Dimensional vector consisting of an X, Y and Z component. Generally used to represent a point in 3D space.

Method Documentation

◆ addVector:

- (ARVector3 *) addVector: (ARVector3 *)  vector

Adds the components of two vectors together and returns the result.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:4.0 y:5.0 z:6.0];
ARVector3 vectorThree = [vectorOne addVector:vectorTwo];
Parameters
vectorThe vector to add to this vector.
Returns
A new ARVector3 with values (X1 + X2, Y1 + Y2, Z1 + Z2).

◆ crossProductWithVector:

- (ARVector3 *) crossProductWithVector: (ARVector3 *)  vector

Calculates the cross product of this vector with the given vector and returns the result.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:2.0 y:3.0 z:4.0];
ARVector3 crossProductVector = [vectorOne crossProductWithVector:vectorTwo];
Parameters
vectorThe 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:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:5.0 y:10.0 z:15.0];
float distance = [vectorOne distanceToVector:vectorTwo];
Parameters
vectorThe 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 oldVector = [ARVector3 vectorWithValuesX:2.0 y:4.0 z:8.0];
ARVector3 newVector = [oldVector divideByScalar:2.0];
Parameters
scalarThe value to divide this vector by.
Returns
A new ARVector3 with values (X / scalar, Y / scalar, Z / scalar).

◆ divideByVector:

- (ARVector3 *) divideByVector: (ARVector3 *)  vector

Divides this vector's components by the components of a given vector a returns the result.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:8.0 y:12.0 z:25.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:2.0 y:3.0 z:5.0];
ARVector3 vectorThree = [vectorOne divideByVector:vectorTwo];
Parameters
vectorThe 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:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:7.0 y:3.0 z:12.0];
float dotProduct = [vectorOne dotProductWithVector:vectorTwo];
Parameters
vectorThe 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:

ARVector3 vectorOne = [ARVector3 vectorWithValues:1.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:1.0 y:1.0 z:1.0];
BOOL isEqual = [vectorOne equalsVector:vectorTwo withTolerance:FLT_EPSILON];
Parameters
vectorThe vector to check against.
toleranceThe 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:

- (ARVector3 *) lerpTo: (ARVector3 *)  vector
atTime: (float)  time 

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 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:-2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:-2.0 y:5.0 z:-8.0];
ARVector3 lerpVector = [vectorOne lerpTo:vectorTwo atTime:0.5];
Parameters
vectorThe other vector to use for the interpolation calculation.
timeRepresents 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:

- (ARVector3 *) localAddVector: (ARVector3 *)  vector

Adds the components of two vectors together and stores the result in this vector.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:4.0 y:5.0 z:6.0];
[vectorOne localAddVector:vectorTwo];
Parameters
vectorThe vector to add to this vector.
Returns
This vector with values (X1 + X2, Y1 + Y2, Z1 + Z2).

◆ localCrossProductWithVector:

- (ARVector3 *) localCrossProductWithVector: (ARVector3 *)  vector

Calculates the cross product of this vector with the given vector and store the result in this vector.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:2.0 y:3.0 z:4.0];
[vectorOne localCrossProductWithVector:vectorTwo];
Parameters
vectorThe other vector to use for the cross product calculation.
Returns
This vector containing the cross product of the two vectors.

◆ localDivideByVector:

- (ARVector3 *) localDivideByVector: (ARVector3 *)  vector

Divides this vector's components by the components of a given vector a stores the result in this vector.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:8.0 y:12.0 z:25.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:2.0 y:3.0 z:5.0];
[vectorOne divideByVector:vectorTwo];
Parameters
vectorThe vector to divide this vector by.
Returns
This vector with values (X1 / X2, Y1 / Y2, Z1 / Z2).

◆ localMultiplyByVector:

- (ARVector3 *) localMultiplyByVector: (ARVector3 *)  vector

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:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:2.0 y:4.0 z:6.0];
[vectorOne localMultiplyByVector:vectorTwo];
Parameters
vectorThe vector to multiply with this vector.
Returns
This vector with values (X1 * X2, Y1 * Y2, Z1 * Z2).

◆ localSubtractVector:

- (ARVector3 *) localSubtractVector: (ARVector3 *)  vector

Subtracts a given vector's components from the componentes this vector and stores the result in this vector.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:4.0 y:5.0 z:6.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:3.0 y:2.0 z:1.0];
[vectorOne subtractVector:vectorTwo];
Parameters
vectorThe 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 oldVector = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 newVector = [oldVector multiplyByScalar:4.0];
Parameters
scalarThe value to multiply this vector by.
Returns
A new ARVector3 with values (X * scalar, Y * scalar, Z * scalar).

◆ multiplyByVector:

- (ARVector3 *) multiplyByVector: (ARVector3 *)  vector

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 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:2.0 y:4.0 z:6.0];
ARVector3 vectorThree = [vectorOne multiplyByVector:vectorTwo];
Parameters
vectorThe vector to multiply with this vector.
Returns
A new ARVector3 with values (X1 * X2, Y1 * Y2, Z1 * Z2).

◆ negate

- (ARVector3 *) 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:

ARVector3 vector = [ARVector3 vectorWithValuesX:3.0 y:4.0 z:12.0];
[vector localNormalise];
@return This vector containing the normalised vector.
/
- (ARVector3 *)localNormalise;
Returns
A new ARVector3 containing the negated vector (-X, -Y, -Z).

◆ normalise

- (ARVector3 *) 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:

ARVector3 vector = [ARVector3 vectorWithValuesX:3.0 y:4.0 z:12.0];
ARVector3 normalisedVector = [vector normalise];
Returns
A new ARVector3 containing the normalised vector.

◆ rotationTo:

- (ARQuaternion *) rotationTo: (ARVector3 *)  vector

Calculates the quaternion rotation between this vector and the given vector and returns the result.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:-3.0 y:4.0 z:9.0];
ARQuaternion rotationToVector = [vectorOne rotationTo:vectorTwo];
Parameters
vectorThe 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
delegateThe delegate to assign to this vector.
selectorThe 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
xThe value to give the X component of this vector.
yThe value to give the Y component of this vector.
zThe value to give the Z component of this vector.

◆ subtractVector:

- (ARVector3 *) subtractVector: (ARVector3 *)  vector

Subtracts a given vector's components from the components of this vector and returns the result.

Example of use:

ARVector3 vectorOne = [ARVector3 vectorWithValuesX:4.0 y:5.0 z:6.0];
ARVector3 vectorTwo = [ARVector3 vectorWithValuesX:3.0 y:2.0 z:1.0];
ARVector3 vectorThree = [vectorOne subtractVector:vectorTwo];
Parameters
vectorThe vector to subtract from this vector.
Returns
A new ARVector3 with values (X1 - X2, Y1 - Y2, Z1 - Z2).

◆ vectorWithValues:

+ (ARVector3 *) vectorWithValues: (float)  v

Creates a new ARVector3 with the given value.

Example of use:

ARVector3 *vector = [ARVector3 vectorWithValues:1.0];

@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:

ARVector3 *vector = [ARVector3 vectorWithValuesX:1.0 y:2.0 z:3.0];
Parameters
xThe X component of the vector.
yThe Y component of the vector.
zThe Z component of the vector.
Returns
An ARVector3 with values (x, y, z);

◆ vectorWithVector:

+ (ARVector3 *) vectorWithVector: (ARVector3 *)  vec

Creates a new ARVector3 with the given vector.

Example of use:

ARVector3 *vector = [ARVector3 vectorWithVector:otherVector];
Parameters
vecThe ARVector3 to get values from.
Returns
An ARVector3 with the same values as the given vector.

◆ vectorWithZero

+ (ARVector3 *) vectorWithZero

Creates a new empty ARVector3.

Example of use:

Returns
An ARVector3 with values (0, 0, 0).

Property Documentation

◆ length

- (float) length
readnonatomicassign

The length, or magnitude, of this vector, equal to sqrt((X * X) + (Y * Y) + (Z * Z)).

◆ x

- (float) x
readwritenonatomicassign

X component of the vector.

◆ y

- (float) y
readwritenonatomicassign

Y component of the vector.

◆ z

- (float) z
readwritenonatomicassign

Z component of the vector.


The documentation for this class was generated from the following files:
ARVector3::y
float y
Definition: ARVector3.h:21
-[ARVector3 normalise]
ARVector3 * normalise()
Definition: ARVector3.mm:219
+[ARVector3 vectorWithZero]
ARVector3 * vectorWithZero()
Definition: ARVector3.mm:45
ARQuaternion
Definition: ARQuaternion.h:10
ARVector3
Definition: ARVector3.h:11
ARVector3::z
float z
Definition: ARVector3.h:26