Ray Tracer  2020
Vector.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef VECTOR_H_INCLUDED
4 #define VECTOR_H_INCLUDED
5 
10 #include "Matrix.h"
11 
25 class Vector : public Matrix {
26 
27 public:
28 
37  Vector(size_t size = 1);
38 
47  Vector(const Vector& vec);
48 
58  Vector(const Matrix& mat);
59 
66  virtual ~Vector();
67 
77  Vector& operator=(const Vector& vec);
78 
90  double& operator()(size_t ix);
91 
102  const double& operator()(size_t ix) const;
103 
112  Vector operator-() const;
113 
123  Vector& operator+=(const Vector& vec);
124 
134  Vector& operator-=(const Vector& vec);
135 
144  Vector& operator*=(double s);
145 
154  Vector& operator/=(double s);
155 
165  double dot(const Vector& vec) const;
166 
176  Vector cross(const Vector& vec) const;
177 
187  double norm() const;
188 
200  double squaredNorm() const;
201 
202 };
203 
215 Vector operator+(const Vector& lhs, const Vector& rhs);
216 
228 Vector operator-(const Vector& lhs, const Vector& rhs);
229 
240 Vector operator*(double s, const Vector& vec);
241 
252 Vector operator*(const Vector& vec, double s);
253 
266 Vector operator/(const Vector& vec, double s);
267 
268 #endif // VECTOR_H_INCLUDED
Matrix class header file.
Colour operator/(const Colour &colour, double s)
Colour-scalar division.
Definition: Colour.cpp:85
Colour operator+(const Colour &lhs, const Colour &rhs)
Colour addition.
Definition: Colour.cpp:35
Colour operator-(const Colour &lhs, const Colour &rhs)
Colour subtraction.
Definition: Colour.cpp:47
Basic class for matrices.
Definition: Matrix.h:22
friend Matrix operator*(const Matrix &lhs, const Matrix &rhs)
Matrix-Matrix multiplication operator.
Definition: Matrix.cpp:151
Basic class for vectors.
Definition: Vector.h:25
Vector & operator=(const Vector &vec)
Vector assignment operator.
Definition: Vector.cpp:27
Vector & operator-=(const Vector &vec)
Vector subtraction-assignment operator.
Definition: Vector.cpp:70
double norm() const
Vector norm.
Definition: Vector.cpp:129
virtual ~Vector()
Vector destructor.
Definition: Vector.cpp:22
Vector(size_t size=1)
Vector constructor.
Definition: Vector.cpp:7
Vector & operator+=(const Vector &vec)
Vector addition-assignment operator.
Definition: Vector.cpp:57
double & operator()(size_t ix)
Vector element access.
Definition: Vector.cpp:35
Vector cross(const Vector &vec) const
Vector cross product.
Definition: Vector.cpp:119
Vector operator-() const
Unary minus.
Definition: Vector.cpp:45
double dot(const Vector &vec) const
Vector dot product.
Definition: Vector.cpp:109
Vector & operator*=(double s)
Vector-scalar multiplication-assignment operator.
Definition: Vector.cpp:90
double squaredNorm() const
SquaredVector norm.
Definition: Vector.cpp:134
Vector & operator/=(double s)
Vector-scalar multiplication-assignment operator.
Definition: Vector.cpp:103