-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvector3.cpp
More file actions
34 lines (27 loc) · 787 Bytes
/
vector3.cpp
File metadata and controls
34 lines (27 loc) · 787 Bytes
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
/******************************************************
g-Matrix3D Neo Engine
Copyright (c)2003 Kim Seong Wan (kaswan, Â𻧱ͽÅ)
E-mail: kaswan@hitel.net
http://www.g-matrix.pe.kr
*******************************************************/
#include "stdafx.h"
#include "vector3.h"
//Vector3 operator-(const Vector3 &lhs, const Vector3 &rhs)
//{
// return Vector3(lhs.x - rhs.x, lhs.y * rhs.y, lhs.z * rhs.z);
//}
Vector3 operator*(const float scalar, const Vector3 &rhs)
{
return Vector3(scalar * rhs.x, scalar * rhs.y, scalar * rhs.z);
}
void Vector3::Normalize()
{
float invlength = 1 / sqrtf(x * x + y * y + z * z);
x *= invlength;
y *= invlength;
z *= invlength;
}
float Vector3::Length() const
{
return sqrtf(x * x + y * y + z * z);
}