MTVector

Class MTVector has subclass: MTCoordinates (3.9).

Class MTVector inherits from class MTMatrix (4.2) and implements the additional methods:

* access
-(NSString*)description returns textual description:

[dim0,dim1,...,dimn-1]

-(NSString*)toString same as -(NSString*)description
-(int)dimension number of dimensions
-(double)atDim:(int)dim returns value at given dimension
-(id)atDim:(int)dim value:(double)v set value at given dimension
* operations
-(double)length returns length of the vector
-(double)euklideanDistanceTo: (MTVector*)v2 distance between two vectors
-(id)differenceTo:(MTVector*)v2 returns difference vector of the two
-(id)add:(MTVector*)v2 add another vector to this one
-(id)scaleByScalar:(double)scalar multiply all coordinates by the scalar
-(id)normalize scale by 1/length so vector becomes of length 1.0
-(double)angleBetween:(MTVector*)v2 calculates angle between two vectors
-(double)scalarProductBy:(MTVector*)v2 v1 * v2
-(id)vectorProductBy:(MTVector*)v2 v1 x v2
-(double)mixedProductBy:(MTVector*)v2 and:(MTVector*)v3 v1*(v2 x v3)
* creation
-(id)setDimensions:(int)dim set dimensions to new length, destroys content
+(MTVector*)vectorWithDimensions: (int)dim create a new vector with given dimensions

moltalk@moltalk.org      version of this document: V3.0