00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _VECTOR_H_
00014 #define _VECTOR_H_
00015
00016 #include <stdexcept>
00017 #include <string>
00018 #include "General/Debug.hh"
00019 #include "General/Types.hh"
00020 #include "Math/Matrix.hh"
00021 #include "Math/Tuple.hh"
00022
00023 namespace Math {
00024
00034 class Vector : public Tuple<Double, false, 3> {
00035 public:
00036 enum {X, Y, Z};
00038 inline Vector(Double x, Double y, Double z) {
00039 D[0] = x;
00040 D[1] = y;
00041 D[2] = z;
00042 }
00043
00045 inline Vector() {
00046 D[0] = D[1] = D[2] = 0.0;
00047 }
00048
00050 inline Vector(const Tuple<Double, false, 3> &T) {
00051 D[0] = T[0];
00052 D[1] = T[1];
00053 D[2] = T[2];
00054 }
00055
00057 friend std::ostream &operator<<(std::ostream &os, const Vector &V);
00058
00060 inline void Set(Double x, Double y, Double z)
00061 {
00062 this->D[0] = x;
00063 this->D[1] = y;
00064 this->D[2] = z;
00065 }
00066
00071 void Transform(const Matrix &M);
00072
00077 Vector operator*(const Matrix &M) const;
00078 using Tuple<Double, false, 3>::operator*;
00079
00082 Vector Cross(const Vector &M) const;
00083
00086 inline Double Dot(const Vector &M) const {
00087 return D[0] * M.D[0] +
00088 D[1] * M.D[1] +
00089 D[2] * M.D[2];
00090 }
00091
00092
00093 };
00094 };
00095
00096 #endif