-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.h
More file actions
24 lines (22 loc) · 795 Bytes
/
vector.h
File metadata and controls
24 lines (22 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once
#include <cmath>
class Vector {
public:
explicit Vector(double x = 0, double y = 0, double z = 0);
double norm2() const;
double norm() const;
void normalize();
double operator[](int i) const;
double& operator[](int i);
Vector operator-() const;
double data[3];
Vector& operator+=(const Vector& other);
friend Vector operator*(const Vector& a, const Vector& b);
};
Vector operator+(const Vector& a, const Vector& b);
Vector operator-(const Vector& a, const Vector& b);
Vector operator*(const double a, const Vector& b);
Vector operator*(const Vector& a, const double b);
Vector operator/(const Vector& a, const double b);
double dot(const Vector& a, const Vector& b);
Vector cross(const Vector& a, const Vector& b);