Not Enough Math
Lightweight zero-dependency C++ math library
Loading...
Searching...
No Matches
vec.hpp File Reference
#include "utils.hpp"
#include "err.hpp"
#include <type_traits>
#include <cstddef>
#include <limits>

Go to the source code of this file.

Classes

struct  nem::storage< _T, _N >
 
struct  nem::storage< _T, 2 >
 
struct  nem::storage< _T, 3 >
 
struct  nem::storage< _T, 4 >
 
struct  nem::vec< _T, _N >
 

Namespaces

namespace  nem
 
namespace  nem::color
 

Macros

#define TEST_VEC_TRAITS(VecType)
 

Typedefs

using nem::int2 = nem::vec<int , 2>
 
using nem::int3 = nem::vec<int , 3>
 
using nem::int4 = nem::vec<int , 4>
 
using nem::float2 = nem::vec<float , 2>
 
using nem::float3 = nem::vec<float , 3>
 
using nem::float4 = nem::vec<float , 4>
 
using nem::double2 = nem::vec<double, 2>
 
using nem::double3 = nem::vec<double, 3>
 
using nem::double4 = nem::vec<double, 4>
 

Functions

static float4 nem::color::rgb (float r, float g, float b)
 
static float4 nem::color::rgba (float r, float g, float b, float a)
 
static float4 nem::color::opaque (float3 rgb)
 
static float4 nem::color::opaque (float4 rgba)
 
static float4 nem::color::transparent (float3 rgb)
 
static float4 nem::color::transparent (float4 rgba)
 

Variables

static constexpr float nem::color::ALPHA_TRANSPARENT = 0.f
 
static constexpr float nem::color::ALPHA_OPAQUE = 1.f
 
static float4 nem::color::clear = rgba(0.f, 0.f, 0.f, ALPHA_TRANSPARENT)
 
static float4 nem::color::white = rgb(1.f, 1.f, 1.f)
 
static float4 nem::color::black = rgb(0.f, 0.f, 0.f)
 
static float4 nem::color::red = rgb(1.f, 0.f, 0.f)
 
static float4 nem::color::green = rgb(0.f, 1.f, 0.f)
 
static float4 nem::color::blue = rgb(0.f, 0.f, 1.f)
 
static float4 nem::color::cyan = rgb(0.f, 1.f, 1.f)
 
static float4 nem::color::yellow = rgb(1.f, 1.f, 0.f)
 

Macro Definition Documentation

◆ TEST_VEC_TRAITS

#define TEST_VEC_TRAITS ( VecType)
Value:
static_assert(sizeof(VecType) == sizeof(VecType::ITEM_TYPE) * VecType::ITEM_COUNT, \
#VecType " size mismatch! Possible unexpected padding."); \
static_assert(std::is_standard_layout_v<VecType>, \
#VecType " is not Standard Layout. This breaks C-compatibility/offsetof."); \
\
static_assert(std::is_trivially_copyable_v<VecType>, \
#VecType " is not trivially copyable. This hurts pass-by-value performance."); \
static_assert(std::is_trivially_destructible_v<VecType>, \
#VecType " has a non-trivial destructor. This prevents it from being in a union."); \
\
static_assert(alignof(VecType) >= alignof(VecType::ITEM_TYPE), \
#VecType " alignment is weaker than its scalar component."); \
\
static_assert(std::is_default_constructible_v<VecType>, \
#VecType " should be default constructible for array allocations."); \
static_assert(std::is_trivially_copy_constructible_v<VecType>, \
#VecType " copy constructor is not trivial."); \
static_assert(std::is_trivially_move_constructible_v<VecType>, \
#VecType " move constructor is not trivial (math types should be POD-like).");

Definition at line 10 of file vec.hpp.