63 lines
829 B
C
63 lines
829 B
C
#ifndef POINT_H
|
|
|
|
#include "vec.h"
|
|
|
|
|
|
// STRUCTURE
|
|
struct Point
|
|
{
|
|
inline Point(void) : x(0), y(0), z(0), w(1) {}
|
|
inline Point(float x, float y, float z) : x(x), y(y), z(z), w(1) {}
|
|
|
|
union
|
|
{
|
|
float e[4];
|
|
|
|
struct
|
|
{
|
|
float x, y, z, w;
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
// OPERATORS
|
|
// v / f
|
|
inline Point operator/(Point v, float f)
|
|
{
|
|
Point result;
|
|
|
|
float inverse = 1.0f / f;
|
|
|
|
result.x = v.x * inverse;
|
|
result.y = v.y * inverse;
|
|
result.z = v.z * inverse;
|
|
|
|
return result;
|
|
}
|
|
|
|
// v /= f
|
|
inline Point &operator/=(Point &v, float f)
|
|
{
|
|
v = v / f;
|
|
|
|
return v;
|
|
}
|
|
|
|
// v1 - v2
|
|
inline Vector operator-(Point v1, Point v2)
|
|
{
|
|
Vector result;
|
|
|
|
result.x = v1.x - v2.x;
|
|
result.y = v1.y - v2.y;
|
|
result.z = v1.z - v2.z;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#define POINT_H
|
|
#endif
|
|
|