/* vector.h
 *
 * Pieter Eendebak ( pte@ddsw.nl )
 *
 */

#ifndef VECTOR_H
#define VECTOR_H

#include "includes.h"

/**
 * This is the class Vector. It represents a general (mathematical) vector.
 * The class is used by krubik but is also usefull for other programs.
 *
 * @short General vector class
 * @see KRubik
 * @author Pieter Eendebak <pte@ddsw.nl>
 * @version 0.4
 */
class Vector
{

public:
	/**
	 * Construct the zero-vector, with length 3.
	 *
 	 */
	Vector ();

	/**
	 * Constructs a zero vector with specified length
	 */
	Vector (int l);

	/**
	 * Constructs a vector in R-3
	 *
	 * @param x The x coordinate of the vector
	 * @param y The y coordinate of the vector
	 * @param z The z coordinate of the vector
	 */
	Vector ( double x, double y, double z);

	/**
	 * Overloaded operator=
	 * @see #set
	 */
	void operator=(Vector v);	

	/**
	 * Overloaded operator=
	 * @see #set
	 */
	void operator=(Vector *v);

	/**
	 * The destrucor method for class Vector
	 */
	~Vector();

	/**
	 * @return Returns a string representation of the vector.
	 */
	char * toString();

	/**
	 * @return length of this vector
	 */
	int size();

	// Vector manipulation functions
	
	/**
	 * @param v copy the values of the vector v to this vector
	 */
	void set( Vector v );

	/**
	 * Create is new vector with length 3 at values x, y, z
	 */
	void set(double x, double y, double z);

	/**
	 * Get value of vector at specified index
	 */
	double get(int i);

	/**
	 * Used for compatibility with old class Vector
	 */
	double& x();
	double& y();
	double& z();

	/**
	 * @return true if this vector is equal to v
	 */
	bool equals( Vector v );

	/**
	 * @return value of vector at index, 0 if index is out of bounds
	 */
	double& operator[] ( int index );

	/**
	 * @return true is vector is zero, else false
	 */
	bool isZero();

	/**
	 * Calculates the inner-produkt of the current vertor with
	 * the argument vector.
	 *
	 * @param v The vector with which to take the innerproduct
	 * @return Returns the inner-product
	 */
	double scalProd(Vector v);

	/**
	 * Overloaded operator *
	 * @see #scalProd
	 */
	double operator* ( Vector v );	

	/**
	 * @return Returns the norm of the vector
	 */
	double norm();
	
	/**
	 * Normalizes the vector, that is multiplies the vector by
	 * the 1 over the norm of the vector.
	 *
	 */
	void Normalize();

	/**
	 * Calculates the angle between 2 vectors.
	 */
	double cosAngle(Vector v);

	/**
	 * Calculate the scalar multiple of the argument with this vector.
	 */
	void scalMult( double s);
	/**
	 * Overloaded operator *
	 * @see #scalMult
	 */
	Vector operator*( double s );

	/**
	 * Overloaded operator *=
	 * @see #scalMult
	 */
	void operator*=( double s );	

	/**
	 * @param v Adds the vector v to the current vector
	 *
	 */
	void addVec( Vector v );
	
	/**
	 * Overloaded operator +, does the same as the function addVec
	 *
	 * @see #addVec
	 */	
	Vector operator+(Vector v);
	
	/**
	 * Overloaded operator +=
	 */
	void operator+=(Vector v);

	/**
	 * @param v Substract v from the current vector.
	 *
	 */
	void subVec( Vector v );

	/**
	 * Overloaded operator -
	 */
	Vector operator-( Vector v );

	/**
	 * Overloaded operator -=
	 * @see #subVec
	 */
	void operator-=(Vector v);

	/**
	 * @param v Copy the vector v to the current vector
	 *
	 */
	void copyVec( Vector v );
	/**
	 * Overloaded function.
	 */
	void copyVec( Vector *v );

	/**
	 * Calculates the cross-product of two vectors.
	 * Note : the vector produkt is only defines for 
	 * two vector's of length 3.
	 *
	 * @param v First vector to calculate cross-product
	 * @param w Second vector
	 */
	void vectorProd( Vector v, Vector w );

private:
	/**
	 * Internally used function
	 */
	void create();
	void create(int);

	double *data;
	int length;

public slots:

};

#endif

Documentation generated by root@localhost.localdomain on Sat Jun 27 15:21:54 MET DST 1998