new Vector()
Constructs a Vector object.
Creates a new Vector from the specified Array or Vector. The default constructor sets all components to zero.
- Source:
- vector.js, line 3
Members
-
<static> backward :Leap.Vector
-
The unit vector pointing backward along the positive z-axis: (0, 0, 1)
Type:
- Source:
- vector.js, line 376
-
<static> down :Leap.Vector
-
The unit vector pointing down along the negative y-axis: (0, -1, 0)
Type:
- Source:
- vector.js, line 385
-
<static> forward :Leap.Vector
-
The unit vector pointing forward along the negative z-axis: (0, 0, -1)
Type:
- Source:
- vector.js, line 394
-
<static> left :Leap.Vector
-
The unit vector pointing left along the negative x-axis: (-1, 0, 0)
Type:
- Source:
- vector.js, line 403
-
<static> right :Leap.Vector
-
The unit vector pointing right along the positive x-axis: (1, 0, 0)
Type:
- Source:
- vector.js, line 412
-
<static> up :Leap.Vector
-
The unit vector pointing up along the positive y-axis: (0, 1, 0)
Type:
- Source:
- vector.js, line 421
-
<static> xAxis :Leap.Vector
-
The x-axis unit vector: (1, 0, 0)
Type:
- Source:
- vector.js, line 430
-
<static> yAxis :Leap.Vector
-
The y-axis unit vector: (0, 1, 0)
Type:
- Source:
- vector.js, line 439
-
<static> zAxis :Leap.Vector
-
The z-axis unit vector: (0, 0, 1)
Type:
- Source:
- vector.js, line 448
-
<static> zero :Leap.Vector
-
The zero vector: (0, 0, 0)
Type:
- Source:
- vector.js, line 457
-
[0] :Float
-
The horizontal component.
Type:
- Float
- Source:
- vector.js, line 44
-
[1] :Float
-
The vertical component.
Type:
- Float
- Source:
- vector.js, line 57
-
[2] :Float
-
The depth component.
Type:
- Float
- Source:
- vector.js, line 70
-
x :Float
-
The horizontal component.
Type:
- Float
- Source:
- vector.js, line 43
-
y :Float
-
The vertical component.
Type:
- Float
- Source:
- vector.js, line 56
-
z :Float
-
The depth component.
Type:
- Float
- Source:
- vector.js, line 69
Methods
-
AngleTo(other) → {Float}
-
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:
Name Type Description other
Leap.Vector A Vector object.
- Source:
- vector.js, line 85
Returns:
The angle between this vector and the specified vector in radians.
- Type
- Float
-
compare(other) → {Boolean}
-
Compare Vector equality component-wise.
Parameters:
Name Type Description other
Leap.Vector A Vector object.
- Source:
- vector.js, line 345
Returns:
- Type
- Boolean
-
Cross(other) → {Leap.Vector}
-
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:
Name Type Description other
Leap.Vector A Vector object.
- Source:
- vector.js, line 109
Returns:
The cross product of this vector and the specified vector.
- Type
- Leap.Vector
-
distanceTo(other) → {Float}
-
The distance between the point represented by this Vector object and a point represented by the specified Vector object.
Parameters:
Name Type Description other
Leap.Vector A Vector object.
- Source:
- vector.js, line 132
Returns:
The distance from this point to the specified point.
- Type
- Float
-
dividedBy(scalar) → {Leap.Vector}
-
Divide vector by a scalar.
Parameters:
Name Type Description scalar
Float - Source:
- vector.js, line 198
Returns:
- Type
- Leap.Vector
-
dot(other) → {Float}
-
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:
Name Type Description other
Leap.Vector A Vector object.
- Source:
- vector.js, line 145
Returns:
The dot product of this vector and the specified vector.
- Type
- Float
-
isValid() → {Boolean}
-
Returns true if all of the vector's components are finite.
If any component is NaN or infinite, then this returns false.
- Source:
- vector.js, line 357
Returns:
- Type
- Boolean
-
magnitude() → {Float}
-
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.
- Source:
- vector.js, line 210
Returns:
The length of this vector.
- Type
- Float
-
magnitudeSquared() → {Float}
-
The square of the magnitude, or length, of this vector.
- Source:
- vector.js, line 225
Returns:
The square of the length of this vector.
- Type
- Float
-
minus(other) → {Leap.Vector}
-
Subtract vectors component-wise.
Parameters:
Name Type Description other
Leap.Vector A Vector object.
- Source:
- vector.js, line 174
Returns:
- Type
- Leap.Vector
-
multiply(scalar) → {Leap.Vector}
-
Multiply vector by a scalar.
Parameters:
Name Type Description scalar
Float - Source:
- vector.js, line 186
Returns:
- Type
- Leap.Vector
-
normalized() → {Leap.Vector}
-
A normalized copy of this vector.
A normalized vector has the same direction as the original vector, but with a length of one.
- Source:
- vector.js, line 236
Returns:
A Vector object with a length of one, pointing in the same direction as this Vector object.
- Type
- Leap.Vector
-
pitch() → {Float}
-
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.
- Source:
- vector.js, line 253
Returns:
The angle of this vector above or below the horizon (x-z plane).
- Type
- Float
-
plus(other) → {Leap.Vector}
-
Add vectors component-wise.
Parameters:
Name Type Description other
Leap.Vector A Vector object.
- Source:
- vector.js, line 162
Returns:
- Type
- Leap.Vector
-
roll() → {Float}
-
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.
- Source:
- vector.js, line 273
Returns:
The angle of this vector above or below the horizon (x-z plane).
- Type
- Float
-
toArray() → {Float[]}
-
Returns the vector as a float array.
- Source:
- vector.js, line 320
Returns:
- Type
- Float[]
-
toString() → {String}
-
Returns a string containing this vector in a human readable format: (x, y, z).
- Source:
- vector.js, line 331
Returns:
- Type
- String
-
yaw() → {Float}
-
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.
- Source:
- vector.js, line 299
Returns:
The angle of this vector to the right or left of the negative z-axis.
- Type
- Float