charles/src/basics.h

60 lines
918 B
C
Raw Normal View History

2013-09-05 22:54:45 -07:00
/* basics.h
*
* Declaration of basic types: Vector.
*
* Eryn Wells <eryn@erynwells.me>
*/
#ifndef __BASICS_H
#define __BASICS_H
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-09 22:47:19 -07:00
Vector3 operator+(Vector3 v);
Vector3 operator*(float a);
Vector3 operator-(Vector3 v);
Vector3 operator-();
2013-09-05 22:54:45 -07:00
2013-09-09 22:47:19 -07:00
float length2();
float length();
float dot(Vector3 v);
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-09 22:47:19 -07:00
Vector3 origin, direction;
};
2013-09-09 22:47:19 -07:00
struct Color
{
Color();
Color(float r, float g, float b, float a);
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-05 22:54:45 -07:00
#endif