1. 4FipS.com
  2. Photos
  3. Videos
  4. Code
  5. Forums
  6. pfQuizzz
  7. About
/*
(c) 2004-14 Filip Stoklas, aka FipS, www.4FipS.com
THIS CODE IS FREE - LICENSED UNDER THE MIT LICENSE
*/

#ifndef FS_HEADER__fs_math_type_h__GUARD
#define FS_HEADER__fs_math_type_h__GUARD

#include "fs_config.h"

#include <utility> // std::pair

namespace fs { namespace math {

struct color3
{
    uint8_t r, g, b;
};

struct color4
{
    uint8_t r, g, b, a;
};

template <typename T>
struct vec2
{
    T x, y;

    vec2 & operator += (const vec2 &v) FS_NOEXCEPT;
    vec2 & operator += (T t) FS_NOEXCEPT;
    vec2 & operator -= (const vec2 &v) FS_NOEXCEPT;
    vec2 & operator -= (T t) FS_NOEXCEPT;
    vec2 & operator *= (const vec2 &v) FS_NOEXCEPT;
    vec2 & operator *= (T t) FS_NOEXCEPT;
    vec2 & operator /= (const vec2 &v) FS_NOEXCEPT;
    vec2 & operator /= (T t) FS_NOEXCEPT;

    const T & operator [] (int i) const FS_NOEXCEPT;
    T & operator [] (int i) FS_NOEXCEPT;
};

using vec2_f = vec2<float>;

template <typename T>
struct vec3
{
    T x, y, z;

    vec3 & operator += (const vec3 &v) FS_NOEXCEPT;
    vec3 & operator += (T t) FS_NOEXCEPT;
    vec3 & operator -= (const vec3 &v) FS_NOEXCEPT;
    vec3 & operator -= (T t) FS_NOEXCEPT;
    vec3 & operator *= (const vec3 &v) FS_NOEXCEPT;
    vec3 & operator *= (T t) FS_NOEXCEPT;
    vec3 & operator /= (const vec3 &v) FS_NOEXCEPT;
    vec3 & operator /= (T t) FS_NOEXCEPT;

    const T & operator [] (int i) const FS_NOEXCEPT;
    T & operator [] (int i) FS_NOEXCEPT;
};

using vec3_f = vec3<float>;

template <typename T>
struct vec4
{
    T x, y, z, w;

    vec4 & operator += (const vec4 &v) FS_NOEXCEPT;
    vec4 & operator += (T t) FS_NOEXCEPT;
    vec4 & operator -= (const vec4 &v) FS_NOEXCEPT;
    vec4 & operator -= (T t) FS_NOEXCEPT;
    vec4 & operator *= (const vec4 &v) FS_NOEXCEPT;
    vec4 & operator *= (T t) FS_NOEXCEPT;
    vec4 & operator /= (const vec4 &v) FS_NOEXCEPT;
    vec4 & operator /= (T t) FS_NOEXCEPT;

    const T & operator [] (int i) const FS_NOEXCEPT;
    T & operator [] (int i) FS_NOEXCEPT;
};

using vec4_f = vec4<float>;

template <typename T>
struct mat4
{
    vec4<T> cx, cy, cz, cw; // columns

    const T & operator [] (int i) const FS_NOEXCEPT;
    T & operator [] (int i) FS_NOEXCEPT;
};

using mat4_f = mat4<float>;

}} // namespace fs::math

#endif // FS_HEADER__fs_math_type_h__GUARD