RealVector an element of R^N


Inherits from: Object : Collection : SequenceableCollection : ArrayedCollection : AbstractArray: AbstractVector


Represents an element of R^N.  Usual operations are implemented.

Note: for 2D and 3D vectors, there are available the classes RealVector2D and RealVector3D which are roughly 10% faster than RealVector.


Creation / Class Methods


*rand (size, lo, hi)

random vector.

size - dimension of vector.

lo , hi - range of values

RealVector.rand(4,-6.0,6.0);


*canonB (i, n)

ith element of canonic base of R^N.

RealVector.canonB(0,6)


Accessing Instance and Class Variables


cross (vector)

cross product:

a × b = (a2b3a3b2) i + (a3b1a1b3) j + (a1b2a2b1) k = (a2b3a3b2, a3b1a1b3, a1b2a2b1).

note that the vectors should be 3 dimensional, and no error checking is done for speed.


RealVector[1,2,3].cross(RealVector[2,5,7])

// the cross product of the cannoic base elements folds into itself

3.collect{ |i|  RealVector.canonB(i, 3) };

3.collect{ |i|  RealVector.canonB(i, 3).cross(RealVector.canonB((i+1).mod(3), 3)) };



asPoint

RealVector[1,2].asPoint;



theta

Short prose description of method.

RealVector[0,1].theta/(2pi)*360