**Properties:**

**Methods:**

- Vector()
- Vector(float _x, float _y, float _z)
- Vector(const Vector &vector)
- angleTo(const Vector &other) const
- backward()
- cross(const Vector &other) const
- distanceTo(const Vector &other) const
- dot(const Vector &other) const
- down()
- forward()
- isValid() const
- left()
- magnitude() const
- magnitudeSquared() const
- normalized() const
- operator!=(const Vector &other) const
- operator*(float scalar) const
- operator*=(float scalar)
- operator+(const Vector &other) const
- operator+=(const Vector &other)
- operator-() const
- operator-(const Vector &other) const
- operator-=(const Vector &other)
- operator/(float scalar) const
- operator/=(float scalar)
- operator==(const Vector &other) const
- operator[](unsigned int index) const
- pitch() const
- right()
- roll() const
- toFloatPointer() const
- toString() const
- toVector3() const
- toVector4(float w=0.0f) const
- up()
- xAxis()
- yAxis()
- yaw() const
- zAxis()
- zero()

The

Vectorstruct represents a three-component mathematical vector or point such as a direction or position in three-dimensional space.The Leap Motion software employs a right-handed Cartesian coordinate system. Values given are in units of real-world millimeters. The origin is centered at the center of the Leap Motion

Controller. The x- and z-axes lie in the horizontal plane, with the x-axis running parallel to the long edge of the device. The y-axis is vertical, with positive values increasing upwards (in contrast to the downward orientation of most computer graphics coordinate systems). The z-axis has positive values increasing away from the computer screen.

Since- 1.0
Public FunctionsfloatangleTo(constVector& other)The angle between this vector and the specified vector in radians.

The angle is measured in the plane formed by the two vectors. The angle returned is always the smaller of the two conjugate angles. Thus

A.angleTo(B) == B.angleTo(A)and is always a positive value less than or equal to pi radians (180 degrees).If either vector has zero length, then this function returns zero.

float angleInRadians =Vector::xAxis().angleTo(Vector::yAxis()); // angleInRadians is PI/2 (90 degrees) -- the angle between the x and y axes

Return- The angle between this vector and the specified vector in radians.
Since- 1.0
Parameters

other-A

Vectorobject.

The cross product of this vector and the specified vector.

The cross product is a vector orthogonal to both original vectors. It has a magnitude equal to the area of a parallelogram having the two vectors as sides. The direction of the returned vector is determined by the right-hand rule. Thus

A.cross(B) == -B.cross(A).VectorcrossProduct = thisVector.cross(thatVector);

Return- The cross product of this vector and the specified vector.
Since- 1.0
Parameters

other-A

Vectorobject.floatdistanceTo(constVector& other)The distance between the point represented by this

Vectorobject and a point represented by the specifiedVectorobject.VectoraPoint =Vector(10, 0, 0);Vectororigin =Vector::zero(); float distance = origin.distanceTo(aPoint); // distance = 10

Return- The distance from this point to the specified point.
Since- 1.0
Parameters

other-A

Vectorobject.floatdot(constVector& other)The dot product of this vector with another vector.

The dot product is the magnitude of the projection of this vector onto the specified vector.

float dotProduct = thisVector.dot(thatVector);

Return- The dot product of this vector and the specified vector.
Since- 1.0
Parameters

other-A

Vectorobject.boolisValid()Returns true if all of the vector’s components are finite.

If any component is NaN or infinite, then this returns false.

bool vectorIsValid = thisVector.isValid();

Since- 1.0
floatmagnitude()The magnitude, or length, of this vector.

The magnitude is the L2 norm, or Euclidean distance between the origin and the point represented by the (x, y, z) components of this

Vectorobject.float length = thisVector.magnitude();

Return- The length of this vector.
Since- 1.0
floatmagnitudeSquared()The square of the magnitude, or length, of this vector.

float lengthSquared = thisVector.magnitudeSquared();

Return- The square of the length of this vector.
Since- 1.0
Vectornormalized()booloperator!=(constVector& other)Compare

Vectorinequality component-wise.

bool vectorsNotEqual = thisVector != thatVector;

Since- 1.0
Vectoroperator*(float scalar)Vector&operator*=(float scalar)Multiply vector by a scalar and assign the product.

Since- 1.0

Add vectors component-wise and assign the sum.

Since- 1.0
Vectoroperator-()

Subtract vectors component-wise and assign the difference.

Since- 1.0
Vectoroperator/(float scalar)Vector&operator/=(float scalar)Divide vector by a scalar and assign the quotient.

Since- 1.0
booloperator==(constVector& other)floatoperator[](unsigned int index)floatpitch()The pitch angle in radians.

Pitch is the angle between the negative z-axis and the projection of the vector onto the y-z plane. In other words, pitch represents rotation around the x-axis. If the vector points upward, the returned angle is between 0 and pi radians (180 degrees); if it points downward, the angle is between 0 and -pi radians.

float pitchInRadians = thisVector.pitch();

Return- The angle of this vector above or below the horizon (x-z plane).
Since- 1.0
floatroll()The roll angle in radians.

Roll is the angle between the y-axis and the projection of the vector onto the x-y plane. In other words, roll represents rotation around the z-axis. If the vector points to the left of the y-axis, then the returned angle is between 0 and pi radians (180 degrees); if it points to the right, the angle is between 0 and -pi radians.

Use this function to get roll angle of the plane to which this vector is a normal. For example, if this vector represents the normal to the palm, then this function returns the tilt or roll of the palm plane compared to the horizontal (x-z) plane.

float rollInRadians = thatVector.roll();

Return- The angle of this vector to the right or left of the y-axis.
Since- 1.0
const float *toFloatPointer()Cast the vector to a float array.

const float *vectorData = thisVector.toFloatPointer(); float x = *vectorData; float y = *(++vectorData); float z = *(++vectorData);

Since- 1.0
std::stringtoString()Returns a string containing this vector in a human readable format: (x, y, z).

Since- 1.0
template < typename Vector3Type >const Vector3TypetoVector3()Convert a

Leap::Vectorto another 3-componentVectortype.The specified type must define a constructor that takes the x, y, and z components as separate parameters.

Since- 1.0
template < typename Vector4Type >const Vector4TypetoVector4(float w = 0.0f)Convert a

Leap::Vectorto another 4-componentVectortype.The specified type must define a constructor that takes the x, y, z, and w components as separate parameters. (The homogeneous coordinate, w, is set to zero by default, but you should typically set it to one for vectors representing a position.)

Since- 1.0
Vector()Creates a new

Vectorwith all components set to zero.

Since- 1.0
Vector(float _x, float _y, float _z)Vector(constVector& vector)floatyaw()The yaw angle in radians.

Yaw is the angle between the negative z-axis and the projection of the vector onto the x-z plane. In other words, yaw represents rotation around the y-axis. If the vector points to the right of the negative z-axis, then the returned angle is between 0 and pi radians (180 degrees); if it points to the left, the angle is between 0 and -pi radians.

float yawInRadians = thisVector.yaw();

Return- The angle of this vector to the right or left of the negative z-axis.
Since- 1.0
Public Membersfloat

xThe horizontal component.

Since- 1.0
float

yThe vertical component.

Since- 1.0
float

zThe depth component.

Since- 1.0
Public Static FunctionsconstVector&backward()The unit vector pointing backward along the positive z-axis: (0, 0, 1)

VectorbackwardVector =Vector::backward();

Since- 1.0
constVector&down()The unit vector pointing down along the negative y-axis: (0, -1, 0)

VectordownVector =Vector::down();

Since- 1.0
constVector&forward()The unit vector pointing forward along the negative z-axis: (0, 0, -1)

VectorforwardVector =Vector::forward();

Since- 1.0
constVector&left()The unit vector pointing left along the negative x-axis: (-1, 0, 0)

VectorleftVector =Vector::left();

Since- 1.0
constVector&right()The unit vector pointing right along the positive x-axis: (1, 0, 0)

VectorrightVector =Vector::right();

Since- 1.0
constVector&up()The unit vector pointing up along the positive y-axis: (0, 1, 0)

VectorupVector =Vector::up();

Since- 1.0
constVector&xAxis()constVector&yAxis()constVector&zAxis()constVector&zero()