-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvec.h
31 lines (27 loc) · 967 Bytes
/
vec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef VEC_H
#define VEC_H
#include <fstream>
#include <iostream>
using namespace std;
class Vec{
public:
float x;
float y;
float z;
Vec();
Vec(float xV);
Vec(float xV, float yV, float zV);
Vec& norm();
Vec operator*(const float &f) const; //defines scalar multiplication -> f acts as a scalar
Vec operator*(const Vec &v) const; //defines vector multiplication -> v acts as a vector
float dotProduct(const Vec &v) const; //defines our inner product for two vectors
Vec operator-(const Vec &v) const; //defines vector subtraction
Vec operator+(const Vec &v) const; //defines vector addition
Vec& operator+=(const Vec &v);
Vec& operator*=(const Vec &v);
Vec operator-() const; //defines negating a vector
float length() const;
float lengthSquared() const;
friend ostream& operator<<(ostream &os, Vec &v);
};
#endif