coord: move base coord class into main namespace
This commit is contained in:
parent
439bb19679
commit
99ba406b4d
@ -20,7 +20,7 @@
|
|||||||
#ifndef __UTIL_COLOUR_HPP
|
#ifndef __UTIL_COLOUR_HPP
|
||||||
#define __UTIL_COLOUR_HPP
|
#define __UTIL_COLOUR_HPP
|
||||||
|
|
||||||
#include "detail/coord.hpp"
|
#include "coord.hpp"
|
||||||
|
|
||||||
#include "json/tree.hpp"
|
#include "json/tree.hpp"
|
||||||
|
|
||||||
@ -29,8 +29,8 @@
|
|||||||
namespace util {
|
namespace util {
|
||||||
/// An RGBA colour POD type.
|
/// An RGBA colour POD type.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct colour : public detail::coord<4,T,detail::rgba> {
|
struct colour : public coord<4,T,detail::rgba> {
|
||||||
using detail::coord<4,T,detail::rgba>::coord;
|
using coord<4,T,detail::rgba>::coord;
|
||||||
|
|
||||||
static const colour WHITE;
|
static const colour WHITE;
|
||||||
static const colour BLACK;
|
static const colour BLACK;
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#ifndef __UTIL_COORD_HPP
|
#ifndef __UTIL_COORD_HPP
|
||||||
#define __UTIL_COORD_HPP
|
#define __UTIL_COORD_HPP
|
||||||
|
|
||||||
#include "../preprocessor.hpp"
|
#include "platform.hpp"
|
||||||
#include "../platform.hpp"
|
#include "preprocessor.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -30,10 +30,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template <size_t,typename> class point;
|
|
||||||
template <size_t,typename> class extent;
|
|
||||||
template <size_t,typename> class vector;
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// tags for accessor names
|
// tags for accessor names
|
||||||
@ -207,10 +203,12 @@ namespace util {
|
|||||||
coord_base<4,T,tags...> ({ v0, v1, v2, v3 })
|
coord_base<4,T,tags...> ({ v0, v1, v2, v3 })
|
||||||
{ ; }
|
{ ; }
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
template <size_t S, typename T, typename ...tags>
|
template <size_t S, typename T, typename ...tags>
|
||||||
struct coord : public coord_init<S,T,tags...> {
|
struct coord : public detail::coord_init<S,T,tags...> {
|
||||||
static_assert (S > 0, "coord dimensions must be strictly positive");
|
static_assert (S > 0, "coord dimensions must be strictly positive");
|
||||||
|
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
@ -220,7 +218,7 @@ namespace util {
|
|||||||
size_t size (void) const { return S; }
|
size_t size (void) const { return S; }
|
||||||
|
|
||||||
// constructors
|
// constructors
|
||||||
using coord_init<S,T,tags...>::coord_init;
|
using detail::coord_init<S,T,tags...>::coord_init;
|
||||||
coord () = default;
|
coord () = default;
|
||||||
|
|
||||||
explicit coord (T v)
|
explicit coord (T v)
|
||||||
@ -242,6 +240,11 @@ namespace util {
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// operation traits
|
||||||
|
template <size_t,typename> class point;
|
||||||
|
template <size_t,typename> class extent;
|
||||||
|
template <size_t,typename> class vector;
|
||||||
|
|
||||||
template <
|
template <
|
||||||
size_t S,
|
size_t S,
|
||||||
typename T,
|
typename T,
|
||||||
@ -256,7 +259,6 @@ namespace util {
|
|||||||
template <size_t S, typename T> struct coord_traits<S,T,point,extent> { typedef point<S,T> result; };
|
template <size_t S, typename T> struct coord_traits<S,T,point,extent> { typedef point<S,T> result; };
|
||||||
template <size_t S, typename T> struct coord_traits<S,T,point,vector> { typedef point<S,T> result; };
|
template <size_t S, typename T> struct coord_traits<S,T,point,vector> { typedef point<S,T> result; };
|
||||||
template <size_t S, typename T> struct coord_traits<S,T,vector,vector> { typedef vector<S,T> result; };
|
template <size_t S, typename T> struct coord_traits<S,T,vector,vector> { typedef vector<S,T> result; };
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
@ -268,10 +270,10 @@ namespace util {
|
|||||||
template <size_t,typename> class A, \
|
template <size_t,typename> class A, \
|
||||||
template <size_t,typename> class B \
|
template <size_t,typename> class B \
|
||||||
> \
|
> \
|
||||||
typename detail::coord_traits<S,T,A,B>::result \
|
typename coord_traits<S,T,A,B>::result \
|
||||||
operator OP (A<S,T> a, B<S,T> b) \
|
operator OP (A<S,T> a, B<S,T> b) \
|
||||||
{ \
|
{ \
|
||||||
typename detail::coord_traits<S,T,A,B>::result out; \
|
typename coord_traits<S,T,A,B>::result out; \
|
||||||
for (size_t i = 0; i < S; ++i) \
|
for (size_t i = 0; i < S; ++i) \
|
||||||
out[i] = a[i] OP b[i]; \
|
out[i] = a[i] OP b[i]; \
|
||||||
return out; \
|
return out; \
|
||||||
@ -283,7 +285,7 @@ namespace util {
|
|||||||
template <size_t,typename> class A, \
|
template <size_t,typename> class A, \
|
||||||
template <size_t,typename> class B \
|
template <size_t,typename> class B \
|
||||||
> \
|
> \
|
||||||
typename detail::coord_traits<S,T,A,B>::result& \
|
typename coord_traits<S,T,A,B>::result& \
|
||||||
operator PASTE(OP,=) (A<S,T>& a, B<S,T> b) \
|
operator PASTE(OP,=) (A<S,T>& a, B<S,T> b) \
|
||||||
{ \
|
{ \
|
||||||
for (size_t i = 0; i < S; ++i) \
|
for (size_t i = 0; i < S; ++i) \
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __UTIL_EXTENT_HPP
|
#ifndef __UTIL_EXTENT_HPP
|
||||||
#define __UTIL_EXTENT_HPP
|
#define __UTIL_EXTENT_HPP
|
||||||
|
|
||||||
#include "detail/coord.hpp"
|
#include "coord.hpp"
|
||||||
#include "vector.hpp"
|
#include "vector.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ namespace util {
|
|||||||
* A pure two-dimensional size, without positioning
|
* A pure two-dimensional size, without positioning
|
||||||
*/
|
*/
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
struct extent : public detail::coord<S,T,detail::whd>
|
struct extent : public coord<S,T,detail::whd>
|
||||||
{
|
{
|
||||||
using detail::coord<S,T,detail::whd>::coord;
|
using coord<S,T,detail::whd>::coord;
|
||||||
|
|
||||||
extent () = default;
|
extent () = default;
|
||||||
extent (vector<S,T>);
|
extent (vector<S,T>);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "extent.hpp"
|
#include "extent.hpp"
|
||||||
#include "vector.hpp"
|
#include "vector.hpp"
|
||||||
#include "detail/coord.hpp"
|
#include "coord.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
@ -32,9 +32,9 @@
|
|||||||
namespace util {
|
namespace util {
|
||||||
/// An n-dimensional position in space.
|
/// An n-dimensional position in space.
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
struct point : public detail::coord<S,T,detail::xyzw>
|
struct point : public coord<S,T,detail::xyzw>
|
||||||
{
|
{
|
||||||
using detail::coord<S,T,detail::xyzw>::coord;
|
using coord<S,T,detail::xyzw>::coord;
|
||||||
|
|
||||||
// point operators
|
// point operators
|
||||||
template <typename U> typename std::common_type<T,U>::type distance (const point<S,U> &) const;
|
template <typename U> typename std::common_type<T,U>::type distance (const point<S,U> &) const;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define __UTIL_VECTOR_HPP
|
#define __UTIL_VECTOR_HPP
|
||||||
|
|
||||||
#include "json/tree.hpp"
|
#include "json/tree.hpp"
|
||||||
#include "detail/coord.hpp"
|
#include "coord.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
struct vector : public detail::coord<S,T,detail::xyzw,detail::stpq> {
|
struct vector : public coord<S,T,detail::xyzw,detail::stpq> {
|
||||||
using detail::coord<S,T,detail::xyzw,detail::stpq>::coord;
|
using coord<S,T,detail::xyzw,detail::stpq>::coord;
|
||||||
|
|
||||||
bool is_zero (void) const;
|
bool is_zero (void) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user