Class myphysicslab.lab.util.Vector
Instance Methods
this.add( vector ) → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns sum of this Vector and given GenericVector.
Parameters 
 

Returns 

this.angleTo( vector ) → number
number
Returns the angle going from this vector to another vector
Parameters 
 

Returns 

this.distanceSquaredTo( point ) → number
number
Returns distancesquared between this Vector and another GenericVector regarding both as points in space. Computationally inexpensive because it only uses multiplication, no square root.
Parameters 
 

Returns 

this.distanceTo( point ) → number
number
Returns distance between this Vector and another GenericVector regarding both as points in space. Computationally expensive because it involves as square root.
Parameters 
 

Returns 

this.divide( factor ) → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns quotient of this Vector and given factor.
Parameters 
 

Returns 
 
Throws 

this.dotProduct( vector ) → number
number
Returns the dot product of this Vector and the given vector.
Parameters 
 

Returns 

this.equals( vector ) → boolean
boolean
Returns true iff the other object is a GenericVector with the same values.
Parameters 
 

Returns 

this.getAngle() → number
number
Returns the angle theta
from the conversion of rectangular coordinates
(x, y)
to polar coordinates (r, theta)
. Uses the JavaScript function
Math.atan2
, see documentation there about special cases.
Parameters  None.  

Returns 

this.getX() → number
number
Returns the X value of the GenericVector.
Specified by  

Parameters  None.  
Returns 

this.getY() → number
number
Returns the Y value of the GenericVector.
Specified by  

Parameters  None.  
Returns 

this.getZ() → number
number
Returns the Z value of the GenericVector.
Specified by  

Parameters  None.  
Returns 

this.immutable() → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns an immutable copy of this vector. Might return itself if this is an immutable vector, otherwise makes a new immutable vector.
Specified by  

Parameters  None.  
Returns 

this.length() → number
number
Returns length of this Vector. Note this is computationally expensive as it involves taking a square root.
Parameters  None.  

Returns 

this.lengthCheap() → number
number
this.lengthSquared() → number
number
Returns length squared of this Vector. Computationally cheap because it only uses multiplication, no square root.
Parameters  None.  

Returns 

this.multiply( factor ) → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns this Vector multiplied by the given factor.
Parameters 
 

Returns 

this.nearEqual( vector, opt_tolerance ) → boolean
boolean
Returns true
if this Vector is nearly equal to another Vector.
The optional tolerance value corresponds to the epsilon
in
myphysicslab.lab.util.UtilityCore#veryDifferent
, so the actual tolerance
used depends on the magnitude of the numbers being compared.
Parameters 
 

Returns 

this.normalize() → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns the normalized version of this Vector, having unit length and the same direction.
Parameters  None.  

Returns 
 
Throws 

this.rotate( angle, sineAngle ) → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns this Vector rotated counterclockwise about the origin by the given angle in radians. If two parameters are given then they are the cosine and sine of the angle (this avoids calculating the sine and cosine which is computationally expensive).
Parameters 
 

Returns 

this.subtract( vector ) → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns difference of this Vector and given Vector.
Parameters 
 

Returns 

this.toString() → string
string
Parameters  None.  

Returns 

Static Functions
Vector.copy( vector ) → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns a new Vector having the same values as the input GenericVector.
Parameters 
 

Returns 

Static Properties
Vector.EAST → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
The vector (1, 0, 0).
Vector.NORTH → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
The vector (0, 1, 0).
Vector.ORIGIN → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
The vector (0, 0, 0).
Vector.SOUTH → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
The vector (0, 1, 0).
Vector.TINY_POSITIVE → number
number
Very small number used to detect zero length vectors in #divide
and
#normalize
.
Vector.WEST → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
The vector (1, 0, 0).