-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector.cpp
More file actions
49 lines (42 loc) · 1.34 KB
/
Copy pathVector.cpp
File metadata and controls
49 lines (42 loc) · 1.34 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Vector.cpp
// raytracer2
//
// Created by Jean Wolff on 11/01/2020.
// Copyright © 2020 Jean Wolff. All rights reserved.
//
#include <stdio.h>
#include "Vector.h"
#include <vector>
#include <random>
static std::default_random_engine engine;
static std::uniform_real_distribution<double> uniform(0, 1);
#define M_pi 3.1416
// & permet de ne pas charger un tableau complet, seulement de prendre la case memoire du bon element
Vector operator+(const Vector& a, const Vector &b) {
return Vector(a[0] + b[0], a[1] + b[1], a[2] + b[2]);
}
Vector operator-(const Vector& a, const Vector &b) {
return Vector(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
}
Vector operator*(double a, const Vector &b) {
return Vector(a*b[0], a*b[1], a*b[2]);
}
Vector operator*(const Vector &a, const Vector &b) {
return Vector(a[0]*b[0], a[1]*b[1], a[2]*b[2]);
}
Vector operator*(const Vector &b, double a) {
return Vector(a*b[0], a*b[1], a*b[2]);
}
Vector operator/(const Vector& a, double b) {
return Vector(a[0]/b, a[1]/b, a[2]/b);
}
Vector operator-(const Vector& a) {
return Vector(-a[0], -a[1], -a[2]);
}
double dot(const Vector& a, const Vector& b) {
return (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]);
}
Vector cross(const Vector& a, const Vector& b) {
return Vector(a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]);
}