2013-09-05 22:54:45 -07:00
|
|
|
/* basics.h
|
|
|
|
*
|
2013-09-09 23:03:41 -07:00
|
|
|
* Declaration of basic types.
|
|
|
|
*
|
|
|
|
* - Vector3 is a three tuple vector of x, y, and z.
|
|
|
|
* - Ray is a vector plus a direction.
|
|
|
|
* - Color is a four tuple of red, green, blue, and alpha.
|
2013-09-05 22:54:45 -07:00
|
|
|
*
|
|
|
|
* Eryn Wells <eryn@erynwells.me>
|
|
|
|
*/
|
|
|
|
|
2013-09-09 23:03:41 -07:00
|
|
|
#ifndef __BASICS_H__
|
|
|
|
#define __BASICS_H__
|
2013-09-05 22:54:45 -07:00
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
struct Vector3
|
|
|
|
{
|
|
|
|
Vector3();
|
|
|
|
Vector3(float x, float y, float z);
|
2013-09-05 22:54:45 -07:00
|
|
|
|
2013-09-10 16:25:12 -07:00
|
|
|
Vector3 &operator=(const Vector3 &v);
|
|
|
|
|
2013-09-10 15:34:08 -07:00
|
|
|
Vector3 operator+(Vector3 v) const;
|
|
|
|
Vector3 operator*(float a) const;
|
|
|
|
Vector3 operator-(Vector3 v) const;
|
|
|
|
Vector3 operator-() const;
|
|
|
|
|
|
|
|
float length2() const;
|
|
|
|
float length() const;
|
|
|
|
float dot(Vector3 v) const;
|
2013-09-05 22:54:45 -07:00
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
void normalize();
|
2013-09-05 22:54:45 -07:00
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
static const Vector3 Zero;
|
|
|
|
float x, y, z;
|
|
|
|
};
|
2013-09-05 22:54:45 -07:00
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
Vector3 operator*(float a, Vector3 v);
|
2013-09-06 19:01:02 -07:00
|
|
|
|
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
struct Ray
|
|
|
|
{
|
|
|
|
Ray();
|
|
|
|
Ray(Vector3 o, Vector3 d);
|
2013-09-06 19:01:02 -07:00
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
Vector3 parameterize(float t);
|
2013-09-06 21:15:56 -07:00
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
Vector3 origin, direction;
|
|
|
|
};
|
2013-09-06 21:15:56 -07:00
|
|
|
|
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
struct Color
|
|
|
|
{
|
|
|
|
Color();
|
|
|
|
Color(float r, float g, float b, float a);
|
2013-09-06 21:15:56 -07:00
|
|
|
|
2013-09-10 16:25:12 -07:00
|
|
|
Color &operator=(const Color &c);
|
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
static const Color Black;
|
|
|
|
static const Color White;
|
|
|
|
static const Color Red;
|
|
|
|
static const Color Green;
|
|
|
|
static const Color Blue;
|
2013-09-07 22:12:35 -07:00
|
|
|
|
2013-09-09 22:47:19 -07:00
|
|
|
float red, green, blue, alpha;
|
|
|
|
};
|
2013-09-06 21:15:56 -07:00
|
|
|
|
2013-09-05 22:54:45 -07:00
|
|
|
#endif
|