clray
view src/vector.cc @ 55:df239a52a091
extensive render stats for the CPU raytracer
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 11 Sep 2010 03:00:21 +0100 |
parents | 51f115e337c2 |
children |
line source
1 #include "vector.h"
3 Vector2::Vector2() : x(0), y(0) {}
5 Vector2::Vector2(float x, float y)
6 {
7 this->x = x;
8 this->y = y;
9 }
12 Vector3::Vector3() : x(0), y(0), z(0) {}
14 Vector3::Vector3(float x, float y, float z)
15 {
16 this->x = x;
17 this->y = y;
18 this->z = z;
19 }
21 Vector3::Vector3(const float *arr)
22 {
23 x = arr[0];
24 y = arr[1];
25 z = arr[2];
26 }
28 void Vector3::normalize()
29 {
30 float len = sqrt(x * x + y * y + z * z);
31 if(len != 0.0) {
32 x /= len;
33 y /= len;
34 z /= len;
35 }
36 }