mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-16 22:19:51 +07:00
123 lines
3.1 KiB
C++
123 lines
3.1 KiB
C++
/*******************************************************************************
|
|
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
|
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
|
* Copyright (C) 2020-2021, by Matvey Cherevko (blackmatov@gmail.com)
|
|
******************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
#include <cmath>
|
|
#include <cstddef>
|
|
#include <cstdlib>
|
|
|
|
#include <initializer_list>
|
|
#include <iterator>
|
|
#include <limits>
|
|
#include <stdexcept>
|
|
#include <type_traits>
|
|
#include <utility>
|
|
|
|
#if defined(_MSC_VER)
|
|
# define VMATH_HPP_FORCE_INLINE __forceinline
|
|
#elif defined(__clang__) || defined(__GNUC__)
|
|
# define VMATH_HPP_FORCE_INLINE inline __attribute__((__always_inline__))
|
|
#else
|
|
# define VMATH_HPP_FORCE_INLINE inline
|
|
#endif
|
|
|
|
#if !defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND)
|
|
# define VMATH_HPP_NO_EXCEPTIONS
|
|
#endif
|
|
|
|
#ifdef VMATH_HPP_NO_EXCEPTIONS
|
|
# define VMATH_HPP_THROW(...) std::abort()
|
|
#else
|
|
# define VMATH_HPP_THROW(...) throw __VA_ARGS__
|
|
#endif
|
|
|
|
#define VMATH_HPP_THROW_IF(pred, ...)\
|
|
( (pred) ? VMATH_HPP_THROW(__VA_ARGS__) : (void)0 )
|
|
|
|
namespace vmath_hpp
|
|
{
|
|
struct uninit_t { explicit uninit_t() = default; };
|
|
inline constexpr uninit_t uninit{};
|
|
}
|
|
|
|
namespace vmath_hpp
|
|
{
|
|
template < typename T, std::size_t Size >
|
|
class vec;
|
|
|
|
using bool2 = vec<bool, 2>;
|
|
using bool3 = vec<bool, 3>;
|
|
using bool4 = vec<bool, 4>;
|
|
|
|
using int2 = vec<int, 2>;
|
|
using int3 = vec<int, 3>;
|
|
using int4 = vec<int, 4>;
|
|
|
|
using uint2 = vec<unsigned, 2>;
|
|
using uint3 = vec<unsigned, 3>;
|
|
using uint4 = vec<unsigned, 4>;
|
|
|
|
using float2 = vec<float, 2>;
|
|
using float3 = vec<float, 3>;
|
|
using float4 = vec<float, 4>;
|
|
|
|
using double2 = vec<double, 2>;
|
|
using double3 = vec<double, 3>;
|
|
using double4 = vec<double, 4>;
|
|
|
|
using size2_t = vec<std::size_t, 2>;
|
|
using size3_t = vec<std::size_t, 3>;
|
|
using size4_t = vec<std::size_t, 4>;
|
|
|
|
using ptrdiff2_t = vec<std::ptrdiff_t, 2>;
|
|
using ptrdiff3_t = vec<std::ptrdiff_t, 3>;
|
|
using ptrdiff4_t = vec<std::ptrdiff_t, 4>;
|
|
}
|
|
|
|
namespace vmath_hpp
|
|
{
|
|
template < typename T, std::size_t Size >
|
|
class mat;
|
|
|
|
using bool2x2 = mat<bool, 2>;
|
|
using bool3x3 = mat<bool, 3>;
|
|
using bool4x4 = mat<bool, 4>;
|
|
|
|
using int2x2 = mat<int, 2>;
|
|
using int3x3 = mat<int, 3>;
|
|
using int4x4 = mat<int, 4>;
|
|
|
|
using uint2x2 = mat<unsigned, 2>;
|
|
using uint3x3 = mat<unsigned, 3>;
|
|
using uint4x4 = mat<unsigned, 4>;
|
|
|
|
using float2x2 = mat<float, 2>;
|
|
using float3x3 = mat<float, 3>;
|
|
using float4x4 = mat<float, 4>;
|
|
|
|
using double2x2 = mat<double, 2>;
|
|
using double3x3 = mat<double, 3>;
|
|
using double4x4 = mat<double, 4>;
|
|
|
|
using size2x2_t = mat<std::size_t, 2>;
|
|
using size3x3_t = mat<std::size_t, 3>;
|
|
using size4x4_t = mat<std::size_t, 4>;
|
|
|
|
using ptrdiff2x2_t = mat<std::ptrdiff_t, 2>;
|
|
using ptrdiff3x3_t = mat<std::ptrdiff_t, 3>;
|
|
using ptrdiff4x4_t = mat<std::ptrdiff_t, 4>;
|
|
}
|
|
|
|
namespace vmath_hpp
|
|
{
|
|
template < typename T >
|
|
class qua;
|
|
|
|
using qfloat = qua<float>;
|
|
using qdouble = qua<double>;
|
|
}
|