fart/util/Vector.h
Josh Holtrop 1af787b9ab added jitter and radius parameters to light objects; not using them yet
git-svn-id: svn://anubis/fart/trunk@255 7f9b0f55-74a9-4bce-be96-3c2cd072584d
2010-06-25 16:37:17 +00:00

37 lines
1.1 KiB
C++

#ifndef VECTOR_H
#define VECTOR_H VECTOR_H
#include <iostream>
class Vector
{
public:
Vector();
Vector(double x, double y, double z);
static Vector randomVector();
double & operator[](int idx) { return m_array[idx]; }
double operator[](int idx) const { return m_array[idx]; }
Vector operator-() const;
Vector & normalize();
double mag() const;
double mag2() const;
double dist_to(const Vector & other) const;
Vector proj(const Vector & target) const;
Vector reflect(const Vector & target) const;
operator double() { return mag(); }
protected:
double m_array[3];
};
std::ostream & operator<<(std::ostream & out, const Vector & v);
double operator%(const Vector & v1, const Vector & v2);
Vector operator*(const Vector & v1, const Vector & v2);
Vector operator+(const Vector & v1, const Vector & v2);
Vector operator-(const Vector & v1, const Vector & v2);
Vector operator*(const Vector & v1, double scale);
Vector operator/(const Vector & v1, double scale);
#endif