Leap Motion C# API Reference  0.8.0
Leap.Vector Class Reference

The Vector struct represents a three-component mathematical vector or point such as a direction or position in three-dimensional space. More...

Inherits IDisposable.

Public Member Functions

float AngleTo (Vector other)
 The angle between this vector and the specified vector in radians.
 
Vector Cross (Vector other)
 The cross product of this vector and the specified vector.
 
float DistanceTo (Vector other)
 The distance between the point represented by this Vector object and a point represented by the specified Vector object.
 
float Dot (Vector other)
 The dot product of this vector with another vector.
 
bool Equals (Vector other)
 Compare Vector equality component-wise.
 
bool IsValid ()
 Returns true if all of the vector's components are finite.
 
float[] ToFloatArray ()
 Convert this vector to an array of three float values: [x,y,z].
 
override string ToString ()
 Returns a string containing this vector in a human readable format: (x, y, z).
 
 Vector ()
 Creates a new Vector with all components set to zero.
 
 Vector (float _x, float _y, float _z)
 Creates a new Vector with the specified component values.
 
 Vector (Vector vector)
 Copies the specified Vector.
 

Static Public Member Functions

static Vector operator* (Vector v1, float scalar)
 Multiply vector by a scalar.
 
static Vector operator* (float scalar, Vector v1)
 Multiply vector by a scalar on the left-hand side.
 
static Vector operator+ (Vector v1, Vector v2)
 Add vectors component-wise.
 
static Vector operator- (Vector v1, Vector v2)
 Subtract vectors component-wise.
 
static Vector operator- (Vector v1)
 Negate a vector.
 
static Vector operator/ (Vector v1, float scalar)
 Divide vector by a scalar.
 

Properties

static Vector Backward [get]
 The unit vector pointing backward along the positive z-axis: (0, 0, 1)
 
static Vector Down [get]
 The unit vector pointing down along the negative y-axis: (0, -1, 0)
 
static Vector Forward [get]
 The unit vector pointing forward along the negative z-axis: (0, 0, -1)
 
static Vector Left [get]
 The unit vector pointing left along the negative x-axis: (-1, 0, 0)
 
float Magnitude [get]
 The magnitude, or length, of this vector.
 
float MagnitudeSquared [get]
 The square of the magnitude, or length, of this vector.
 
Vector Normalized [get]
 A normalized copy of this vector.
 
float Pitch [get]
 The pitch angle in radians.
 
static Vector Right [get]
 The unit vector pointing right along the positive x-axis: (1, 0, 0)
 
float Roll [get]
 The roll angle in radians.
 
static Vector Up [get]
 The unit vector pointing up along the positive y-axis: (0, 1, 0)
 
float x [get, set]
 The horizontal component.
 
static Vector XAxis [get]
 The x-axis unit vector: (1, 0, 0)
 
float y [get, set]
 The vertical component.
 
float Yaw [get]
 The yaw angle in radians.
 
static Vector YAxis [get]
 The y-axis unit vector: (0, 1, 0)
 
float z [get, set]
 The depth component.
 
static Vector ZAxis [get]
 The z-axis unit vector: (0, 0, 1)
 
static Vector Zero [get]
 The zero vector: (0, 0, 0)
 

Detailed Description

The Vector struct 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 device. 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.

Constructor & Destructor Documentation

Leap.Vector.Vector ( )
inline

Creates a new Vector with all components set to zero.

Leap.Vector.Vector ( float  _x,
float  _y,
float  _z 
)
inline

Creates a new Vector with the specified component values.

Leap.Vector.Vector ( Vector  vector)
inline

Copies the specified Vector.

Member Function Documentation

float Leap.Vector.AngleTo ( Vector  other)
inline

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.

Parameters
otherA Vector object.
Returns
The angle between this vector and the specified vector in radians.
Vector Leap.Vector.Cross ( Vector  other)
inline

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).

Parameters
otherA Vector object.
Returns
The cross product of this vector and the specified vector.
float Leap.Vector.DistanceTo ( Vector  other)
inline

The distance between the point represented by this Vector object and a point represented by the specified Vector object.

Parameters
otherA Vector object.
Returns
The distance from this point to the specified point.
float Leap.Vector.Dot ( Vector  other)
inline

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.

Parameters
otherA Vector object.
Returns
The dot product of this vector and the specified vector.
bool Leap.Vector.Equals ( Vector  other)
inline

Compare Vector equality component-wise.

bool Leap.Vector.IsValid ( )
inline

Returns true if all of the vector's components are finite.

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

static Vector Leap.Vector.operator* ( Vector  v1,
float  scalar 
)
inlinestatic

Multiply vector by a scalar.

static Vector Leap.Vector.operator* ( float  scalar,
Vector  v1 
)
inlinestatic

Multiply vector by a scalar on the left-hand side.

static Vector Leap.Vector.operator+ ( Vector  v1,
Vector  v2 
)
inlinestatic

Add vectors component-wise.

static Vector Leap.Vector.operator- ( Vector  v1,
Vector  v2 
)
inlinestatic

Subtract vectors component-wise.

static Vector Leap.Vector.operator- ( Vector  v1)
inlinestatic

Negate a vector.

static Vector Leap.Vector.operator/ ( Vector  v1,
float  scalar 
)
inlinestatic

Divide vector by a scalar.

float [] Leap.Vector.ToFloatArray ( )
inline

Convert this vector to an array of three float values: [x,y,z].

override string Leap.Vector.ToString ( )
inline

Returns a string containing this vector in a human readable format: (x, y, z).

Property Documentation

Vector Leap.Vector.Backward
staticget

The unit vector pointing backward along the positive z-axis: (0, 0, 1)

Vector backwardVector = Vector.Backward;
Vector Leap.Vector.Down
staticget

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

Vector downVector = Vector.Down;
Vector Leap.Vector.Forward
staticget

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

Vector forwardVector = Vector.Forward;
Vector Leap.Vector.Left
staticget

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

Vector leftVector = Vector.Left;
float Leap.Vector.Magnitude
get

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 Vector object.

float length = thisVector.Magnitude;
Returns
The length of this vector.
float Leap.Vector.MagnitudeSquared
get

The square of the magnitude, or length, of this vector.

float lengthSquared = thisVector.MagnitudeSquared;
Returns
The square of the length of this vector.
Vector Leap.Vector.Normalized
get

A normalized copy of this vector.

A normalized vector has the same direction as the original vector, but with a length of one.

Vector normalizedVector = otherVector.Normalized;
Returns
A Vector object with a length of one, pointing in the same direction as this Vector object.
float Leap.Vector.Pitch
get

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.

Math_Pitch_Angle.png
float pitchInRadians = thisVector.Pitch;
Returns
The angle of this vector above or below the horizon (x-z plane).
Vector Leap.Vector.Right
staticget

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

Vector rightVector = Vector.Right;
float Leap.Vector.Roll
get

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.

Math_Roll_Angle.png

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;
Returns
The angle of this vector to the right or left of the y-axis.
Vector Leap.Vector.Up
staticget

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

Vector upVector = Vector.Up;
float Leap.Vector.x
getset

The horizontal component.

Vector Leap.Vector.XAxis
staticget

The x-axis unit vector: (1, 0, 0)

Vector xAxisVector = Vector.XAxis;
float Leap.Vector.y
getset

The vertical component.

float Leap.Vector.Yaw
get

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.

Math_Yaw_Angle.png
float yawInRadians = thisVector.Yaw;
Returns
The angle of this vector to the right or left of the negative z-axis.
Vector Leap.Vector.YAxis
staticget

The y-axis unit vector: (0, 1, 0)

Vector yAxisVector = Vector.YAxis;
float Leap.Vector.z
getset

The depth component.

Vector Leap.Vector.ZAxis
staticget

The z-axis unit vector: (0, 0, 1)

Vector zAxisVector = Vector.ZAxis;
Vector Leap.Vector.Zero
staticget

The zero vector: (0, 0, 0)

Vector zeroVector = Vector.Zero;