#ifndef __VECTOR3D_H_INCLUDED__
#define __VECTOR3D_H_INCLUDED__
#include
#include "matrix.h"
#include "vector.h"
#include "quaternion.h"
using namespace std;
class Matrix3X3;
class Quaternion;
/*
The Vector3D class: represents a 3 dimensional vector. Only has 3 variables: x, y, and z for displacement.
*/
class Vector3D {
public:
/*Variables:
I didn't make x, y, and z private, as the programmer should already know the inner workings
of a vector, and would figure that there would be an x, y, and z variables. Plus, I hate the
look of setX(int x) and getX() :D .
*/
float x, y, z;
/*Constructors / Deconstructors:
Vector3D v: x, y, and z are all undefined.
Vector3D v2(1, 2, 3): x, y, and z are set to 1, 2, and 3, respectivly.
Vector3D v3(Vector3D v4): v3.x, v3.y, and v3.z are all set to v4.x, v4.y, and v4.z, respectivly.
~Vector3D(): Deconstructs the vector.
*/
Vector3D() {}
Vector3D(float a, float b, float c) : x(a), y(b), z(c) {}
Vector3D(const Vector3D &v) : x(v.x), y(v.y), z(v.z) {}
~Vector3D() {}
/*Operator overloadings:
Vector3D operator+(const Vector3D &v): x, y, and z are added to v.x, v.y, and v.z, respectivly.
Vector3D operator-(const Vector3D &v): x, y, and z are subtracted from v.x, v.y, and v.z, respectivly.
Vector3D operator*(float w): x, y, and z are all multiplied by w.
Vector3D operator/(float w): x, y, and z are all divided by w.
Vector3D operator-(): negate the vector - x, y, and z are set to -x, -y, and -z, respectivly
Vector3D &operator+=(const Vector3D &v): x, y, and z are added to v.x, v.y, and v.z, respectivly, and vector is set with new values.
Vector3D &operator-=(const Vector3D &v): x, y, and z are subtracted from v.x, v.y, and v.z, respectivly, and vector is set with new values.
Vector3D &operator*=(float w): x, y, and z are all multiplied by w, and vector is set with new values.
Vector3D &operator/=(float w): x, y, and z are all divided by w, and vector is set with new values.
Vector3D &operator=(const Vector3D &v): this vector is set to v.
bool operator==(const Vector3D &v): returns true if Vector3Ds' are equal, false otherwise.
bool operator!=(const Vector3D &v): returns true if Vector3Ds' are not equal, false otherwise.
*/
const Vector3D operator+(const Vector3D &v) const;
const Vector3D operator-(const Vector3D &v) const;
const Vector3D operator*(float w) const;
const Vector3D operator/(float w) const;
Vector3D operator-() const;
Vector3D &operator+=(const Vector3D &v);
Vector3D &operator-=(const Vector3D &v);
Vector3D &operator*=(float w);
Vector3D &operator/=(float w);
Vector3D &operator=(const Vector3D &v);
bool operator==(const Vector3D &v) const;
bool operator!=(const Vector3D &v) const;
/*Other functions:
float length(): returns the length of the vector.
void normalize(): normalize the vector, vector / length of vector
float dotProduct(const Vector3D &v): returns the dotProduct, x * v.x + y * v.y + z * v.z
Vector3D crossProduct(const Vector3D &v): returns cross product between this vector and v.
float distance(const Vector3D &v): returns distance between this vector and v.
*/
float length() const;
void normalize();
float dotProduct(const Vector3D &v) const;
Vector3D crossProduct(const Vector3D &v) const;
float distance(const Vector3D &v) const;
};
#endif