Remove trash files
This commit is contained in:
parent
f622a55c5c
commit
2756d676f1
1 changed files with 0 additions and 73 deletions
73
vec3.h
73
vec3.h
|
|
@ -1,73 +0,0 @@
|
||||||
#ifndef VEC3_H
|
|
||||||
#define VEC3_H
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
struct vec3 {
|
|
||||||
/* Members */
|
|
||||||
double x;
|
|
||||||
double y;
|
|
||||||
double z;
|
|
||||||
|
|
||||||
/* Constructors */
|
|
||||||
|
|
||||||
// Default
|
|
||||||
vec3() { x = 0; y = 0; z = 0; };
|
|
||||||
|
|
||||||
// Constructor proper. Values default to 0
|
|
||||||
vec3(double x = 0, double y = 0, double z = 0)
|
|
||||||
{
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Overriden operators */
|
|
||||||
|
|
||||||
// - operator. Not to be confused with substraction
|
|
||||||
vec3 operator-()
|
|
||||||
{
|
|
||||||
return vec3(-x, -y, -z);
|
|
||||||
}
|
|
||||||
|
|
||||||
// straightforward vector sum
|
|
||||||
vec3& operator+=(const vec3 &v)
|
|
||||||
{
|
|
||||||
this.x += v.x;
|
|
||||||
this.y += v.y;
|
|
||||||
this.z += v.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
// scalar multiplication
|
|
||||||
vec3& operator*=(const double t)
|
|
||||||
{
|
|
||||||
x *= t;
|
|
||||||
y *= t;
|
|
||||||
z *= t;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// division by a scalar t
|
|
||||||
vec3& operator/=(const double t)
|
|
||||||
{
|
|
||||||
x /= t;
|
|
||||||
y /= t;
|
|
||||||
z /= t;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Methods */
|
|
||||||
|
|
||||||
double length()
|
|
||||||
{
|
|
||||||
std::sqrt(x*x + y*y + z*z);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Type aliases */
|
|
||||||
typedef point3 vec3;
|
|
||||||
typedef color vec3;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue