clray

annotate src/vector.cc @ 60:8c858e1a89e8

minor cleanups
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 28 Dec 2015 09:08:49 +0200
parents 51f115e337c2
children
rev   line source
nuclear@23 1 #include "vector.h"
nuclear@23 2
nuclear@23 3 Vector2::Vector2() : x(0), y(0) {}
nuclear@23 4
nuclear@23 5 Vector2::Vector2(float x, float y)
nuclear@23 6 {
nuclear@23 7 this->x = x;
nuclear@23 8 this->y = y;
nuclear@23 9 }
nuclear@23 10
nuclear@23 11
nuclear@23 12 Vector3::Vector3() : x(0), y(0), z(0) {}
nuclear@23 13
nuclear@23 14 Vector3::Vector3(float x, float y, float z)
nuclear@23 15 {
nuclear@23 16 this->x = x;
nuclear@23 17 this->y = y;
nuclear@23 18 this->z = z;
nuclear@23 19 }
nuclear@23 20
nuclear@54 21 Vector3::Vector3(const float *arr)
nuclear@54 22 {
nuclear@54 23 x = arr[0];
nuclear@54 24 y = arr[1];
nuclear@54 25 z = arr[2];
nuclear@54 26 }
nuclear@54 27
nuclear@23 28 void Vector3::normalize()
nuclear@23 29 {
nuclear@23 30 float len = sqrt(x * x + y * y + z * z);
nuclear@23 31 if(len != 0.0) {
nuclear@23 32 x /= len;
nuclear@23 33 y /= len;
nuclear@23 34 z /= len;
nuclear@23 35 }
nuclear@23 36 }