|
|
|
@ -12,10 +12,10 @@ struct Vector
|
|
|
|
|
|
|
|
|
|
inline void Normalize(void)
|
|
|
|
|
{
|
|
|
|
|
float length = sqrtf(x*x + y*y + z*z);
|
|
|
|
|
float length = Length();
|
|
|
|
|
|
|
|
|
|
// zero length
|
|
|
|
|
if (length < EPSILON_E3)
|
|
|
|
|
if (length == 0.0f)
|
|
|
|
|
{
|
|
|
|
|
x = 0.0f;
|
|
|
|
|
y = 0.0f;
|
|
|
|
@ -31,6 +31,19 @@ struct Vector
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline float Length(void)
|
|
|
|
|
{
|
|
|
|
|
float result = sqrtf(x*x + y*y + z*z);
|
|
|
|
|
|
|
|
|
|
// zero length
|
|
|
|
|
if (result < EPSILON_E3)
|
|
|
|
|
{
|
|
|
|
|
result = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static float Dot(Vector v1, Vector v2)
|
|
|
|
|
{
|
|
|
|
|
float result;
|
|
|
|
@ -96,6 +109,18 @@ inline Vector &operator+=(Vector &v1, Vector v2)
|
|
|
|
|
return v1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// f * v
|
|
|
|
|
inline Vector operator*(float f, Vector &v)
|
|
|
|
|
{
|
|
|
|
|
Vector result;
|
|
|
|
|
|
|
|
|
|
result.x = v.x * f;
|
|
|
|
|
result.y = v.y * f;
|
|
|
|
|
result.z = v.z * f;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v / f
|
|
|
|
|
inline Vector operator/(Vector v, float f)
|
|
|
|
|
{
|
|
|
|
|