$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r84868 - in trunk/boost/geometry/extensions/algebra: core geometries geometries/concepts
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-21 15:30:39
Author: awulkiew
Date: 2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)
New Revision: 84868
URL: http://svn.boost.org/trac/boost/changeset/84868
Log:
[geometry][extensions]: added Matrix and Quaternion concepts.
Added:
   trunk/boost/geometry/extensions/algebra/geometries/concepts/matrix_concept.hpp   (contents, props changed)
   trunk/boost/geometry/extensions/algebra/geometries/concepts/quaternion_concept.hpp   (contents, props changed)
   trunk/boost/geometry/extensions/algebra/geometries/matrix.hpp   (contents, props changed)
   trunk/boost/geometry/extensions/algebra/geometries/quaternion.hpp   (contents, props changed)
Text files modified: 
   trunk/boost/geometry/extensions/algebra/core/access.hpp                            |    37 ++++++++++                              
   trunk/boost/geometry/extensions/algebra/core/coordinate_dimension.hpp              |    11 +++                                     
   trunk/boost/geometry/extensions/algebra/core/coordinate_system.hpp                 |    17 ++++                                    
   trunk/boost/geometry/extensions/algebra/core/coordinate_type.hpp                   |    17 ++++                                    
   trunk/boost/geometry/extensions/algebra/core/tags.hpp                              |     3                                         
   trunk/boost/geometry/extensions/algebra/geometries/concepts/matrix_concept.hpp     |   141 ++++++++++++++++++++++++++++++++++++++++
   trunk/boost/geometry/extensions/algebra/geometries/concepts/quaternion_concept.hpp |   111 +++++++++++++++++++++++++++++++         
   trunk/boost/geometry/extensions/algebra/geometries/matrix.hpp                      |   131 +++++++++++++++++++++++++++++++++++++   
   trunk/boost/geometry/extensions/algebra/geometries/quaternion.hpp                  |   130 ++++++++++++++++++++++++++++++++++++    
   9 files changed, 598 insertions(+), 0 deletions(-)
Modified: trunk/boost/geometry/extensions/algebra/core/access.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algebra/core/access.hpp	Fri Jun 21 14:16:47 2013	(r84867)
+++ trunk/boost/geometry/extensions/algebra/core/access.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -56,6 +56,43 @@
 };
 
 template <typename Q, typename CoordinateType, std::size_t Dimension>
+struct access<quaternion_tag, Q, CoordinateType, Dimension, boost::false_type>
+{
+    static inline CoordinateType get(Q const& v)
+    {
+        return traits::access<Q, Dimension>::get(v);
+    }
+    static inline void set(Q& v, CoordinateType const& value)
+    {
+        traits::access<Q, Dimension>::set(v, value);
+    }
+};
+
+template <typename Q, typename CoordinateType, std::size_t Dimension>
+struct access<quaternion_tag, Q, CoordinateType, Dimension, boost::true_type>
+{
+    static inline CoordinateType get(Q const* v)
+    {
+        return traits::access<typename boost::remove_pointer<Q>::type, Dimension>::get(*v);
+    }
+    static inline void set(Q* v, CoordinateType const& value)
+    {
+        traits::access<typename boost::remove_pointer<Q>::type, Dimension>::set(*v, value);
+    }
+};
+
+template<typename M, typename CoordinateType, std::size_t I, std::size_t J>
+struct indexed_access<matrix_tag, M, CoordinateType, I, J, boost::false_type>
+    : detail::indexed_access_non_pointer<M, CoordinateType, I, J>
+{};
+
+template<typename M, typename CoordinateType, std::size_t I, std::size_t J>
+struct indexed_access<matrix_tag, M, CoordinateType, I, J, boost::true_type>
+    : detail::indexed_access_pointer<M, CoordinateType, I, J>
+{};
+
+
+template <typename Q, typename CoordinateType, std::size_t Dimension>
 struct access<rotation_quaternion_tag, Q, CoordinateType, Dimension, boost::false_type>
 {
     static inline CoordinateType get(Q const& v)
Modified: trunk/boost/geometry/extensions/algebra/core/coordinate_dimension.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algebra/core/coordinate_dimension.hpp	Fri Jun 21 14:16:47 2013	(r84867)
+++ trunk/boost/geometry/extensions/algebra/core/coordinate_dimension.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -30,6 +30,17 @@
 {};
 
 template <typename G>
+struct dimension<quaternion_tag, G>
+    : traits::dimension<typename geometry::util::bare_type<G>::type>
+{};
+
+template <typename G, std::size_t Index>
+struct indexed_dimension<matrix_tag, G, Index>
+    : traits::indexed_dimension<typename geometry::util::bare_type<G>::type, Index>
+{};
+
+
+template <typename G>
 struct dimension<rotation_quaternion_tag, G>
     : traits::dimension<typename geometry::util::bare_type<G>::type>
 {};
Modified: trunk/boost/geometry/extensions/algebra/core/coordinate_system.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algebra/core/coordinate_system.hpp	Fri Jun 21 14:16:47 2013	(r84867)
+++ trunk/boost/geometry/extensions/algebra/core/coordinate_system.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -32,6 +32,23 @@
     >::type type;
 };
 
+//template <typename G>
+//struct coordinate_system<quaternion_tag, G>
+//{
+//    typedef typename traits::coordinate_system<
+//        typename geometry::util::bare_type<G>::type
+//    >::type type;
+//};
+//
+//template <typename G>
+//struct coordinate_system<matrix_tag, G>
+//{
+//    typedef typename traits::coordinate_system<
+//        typename geometry::util::bare_type<G>::type
+//    >::type type;
+//};
+
+
 template <typename G>
 struct coordinate_system<rotation_quaternion_tag, G>
 {
Modified: trunk/boost/geometry/extensions/algebra/core/coordinate_type.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algebra/core/coordinate_type.hpp	Fri Jun 21 14:16:47 2013	(r84867)
+++ trunk/boost/geometry/extensions/algebra/core/coordinate_type.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -33,6 +33,23 @@
 };
 
 template <typename G>
+struct coordinate_type<quaternion_tag, G>
+{
+    typedef typename traits::coordinate_type<
+        typename geometry::util::bare_type<G>::type
+    >::type type;
+};
+
+template <typename G>
+struct coordinate_type<matrix_tag, G>
+{
+    typedef typename traits::coordinate_type<
+        typename geometry::util::bare_type<G>::type
+    >::type type;
+};
+
+
+template <typename G>
 struct coordinate_type<rotation_quaternion_tag, G>
 {
     typedef typename traits::coordinate_type<
Modified: trunk/boost/geometry/extensions/algebra/core/tags.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algebra/core/tags.hpp	Fri Jun 21 14:16:47 2013	(r84867)
+++ trunk/boost/geometry/extensions/algebra/core/tags.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -21,6 +21,9 @@
 
 
 struct vector_tag {};
+struct quaternion_tag {};
+struct matrix_tag {};
+
 struct rotation_quaternion_tag {};
 struct rotation_matrix_tag {};
 
Added: trunk/boost/geometry/extensions/algebra/geometries/concepts/matrix_concept.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/geometry/extensions/algebra/geometries/concepts/matrix_concept.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -0,0 +1,141 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_CONCEPTS_MATRIX_CONCEPT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_CONCEPTS_MATRIX_CONCEPT_HPP
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/access.hpp>
+
+namespace boost { namespace geometry { namespace concept {
+
+template <typename Geometry>
+class Matrix
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    typedef typename coordinate_type<Geometry>::type ctype;
+    typedef typename coordinate_system<Geometry>::type csystem;
+
+    enum { ccount = dimension<Geometry>::value };
+
+    template <typename G, std::size_t I, std::size_t J, std::size_t N>
+    struct dimension_checker_row
+    {
+        static void apply()
+        {
+            G* g = 0;
+            geometry::set<I, J>(*g, geometry::get<I, J>(*g));
+            dimension_checker_row<G, I, J+1, N>::apply();
+        }
+    };
+
+    template <typename G, std::size_t I, std::size_t N>
+    struct dimension_checker_row<G, I, N, N>
+    {
+        static void apply() {}
+    };
+
+    template <typename G, std::size_t I, std::size_t N>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            dimension_checker_row<G, I, 0, N>;
+            dimension_checker<G, I+1, N>::apply();
+        }
+    };
+
+    template <typename G, std::size_t N>
+    struct dimension_checker<G, N, N>
+    {
+        static void apply() {}
+    };
+
+public:
+
+    /// BCCL macro to apply the concept
+    BOOST_CONCEPT_USAGE(Matrix)
+    {
+        static const bool cs_check = ::boost::is_same<csystem, cs::cartesian>::value;
+        BOOST_MPL_ASSERT_MSG(cs_check, NOT_IMPLEMENTED_FOR_THIS_CS, (csystem));
+
+        dimension_checker<Geometry, 0, ccount>::apply();
+    }
+#endif
+};
+
+
+template <typename Geometry>
+class ConstMatrix
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    //typedef typename coordinate_type<Geometry>::type ctype;
+    //typedef typename coordinate_system<Geometry>::type csystem;
+
+    //enum { ccount = dimension<Geometry>::value };
+
+    template <typename G, std::size_t I, std::size_t J, std::size_t N>
+    struct dimension_checker_row
+    {
+        static void apply()
+        {
+            const G* g = 0;
+            ctype coord(geometry::get<I, J>(*g));
+            boost::ignore_unused_variable_warning(coord);
+            dimension_checker_row<G, I, J+1, N>::apply();
+        }
+    };
+
+    template <typename G, std::size_t I, std::size_t N>
+    struct dimension_checker_row<G, I, N, N>
+    {
+        static void apply() {}
+    };
+
+    template <typename G, std::size_t I, std::size_t N>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            dimension_checker_row<G, I, 0, N>;
+            dimension_checker<G, I+1, N>::apply();
+        }
+    };
+
+    template <typename G, std::size_t N>
+    struct dimension_checker<G, N, N>
+    {
+        static void apply() {}
+    };
+
+public:
+
+    /// BCCL macro to apply the concept
+    BOOST_CONCEPT_USAGE(ConstMatrix)
+    {
+        //static const bool cs_check = ::boost::is_same<csystem, cs::cartesian>::value;
+        //BOOST_MPL_ASSERT_MSG(cs_check, NOT_IMPLEMENTED_FOR_THIS_CS, (csystem));
+
+        //dimension_checker<Geometry, 0, ccount>::apply();
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_CONCEPTS_MATRIX_CONCEPT_HPP
Added: trunk/boost/geometry/extensions/algebra/geometries/concepts/quaternion_concept.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/geometry/extensions/algebra/geometries/concepts/quaternion_concept.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -0,0 +1,111 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_CONCEPTS_QUATERNION_CONCEPT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_CONCEPTS_QUATERNION_CONCEPT_HPP
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/access.hpp>
+
+namespace boost { namespace geometry { namespace concept {
+
+template <typename Geometry>
+class Quaternion
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    //typedef typename coordinate_type<Geometry>::type ctype;
+    //typedef typename coordinate_system<Geometry>::type csystem;
+
+    template <typename G, std::size_t I, std::size_t N>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            G* g = 0;
+            geometry::set<I>(*g, geometry::get<I>(*g));
+            dimension_checker<G, I+1, N>::apply();
+        }
+    };
+
+
+    template <typename G, std::size_t N>
+    struct dimension_checker<G, N, N>
+    {
+        static void apply() {}
+    };
+
+public:
+
+    /// BCCL macro to apply the Vector concept
+    BOOST_CONCEPT_USAGE(Quaternion)
+    {
+        //static const bool dim_check = dimension<Geometry>::value == 4;
+        //BOOST_MPL_ASSERT_MSG(dim_check, INVALID_DIMENSION, (RotationQuaternion));
+        //static const bool cs_check = ::boost::is_same<csystem, cs::cartesian>::value;
+        //BOOST_MPL_ASSERT_MSG(cs_check, NOT_IMPLEMENTED_FOR_THIS_CS, (csystem));
+
+        dimension_checker<Geometry, 0, 4>::apply();
+    }
+#endif
+};
+
+
+template <typename Geometry>
+class ConstQuaternion
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    //typedef typename coordinate_type<Geometry>::type ctype;
+    //typedef typename coordinate_system<Geometry>::type csystem;
+
+    template <typename G, std::size_t I, std::size_t N>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            const G* g = 0;
+            ctype coord(geometry::get<I>(*g));
+            boost::ignore_unused_variable_warning(coord);
+            dimension_checker<G, I+1, N>::apply();
+        }
+    };
+
+
+    template <typename G, std::size_t N>
+    struct dimension_checker<G, N, N>
+    {
+        static void apply() {}
+    };
+
+public:
+
+    /// BCCL macro to apply the ConstVector concept
+    BOOST_CONCEPT_USAGE(ConstQuaternion)
+    {
+        //static const bool dim_check = dimension<Geometry>::value == 4;
+        //BOOST_MPL_ASSERT_MSG(dim_check, INVALID_DIMENSION, (ConstRotationQuaternion));
+        //static const bool cs_check = ::boost::is_same<csystem, cs::cartesian>::value;
+        //BOOST_MPL_ASSERT_MSG(cs_check, NOT_IMPLEMENTED_FOR_THIS_CS, (csystem));
+
+        dimension_checker<Geometry, 0, 4>::apply();
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_CONCEPTS_QUATERNION_CONCEPT_HPP
Added: trunk/boost/geometry/extensions/algebra/geometries/matrix.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/geometry/extensions/algebra/geometries/matrix.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -0,0 +1,131 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_MATRIX_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_MATRIX_HPP
+
+#include <cstddef>
+
+#include <boost/geometry/extensions/algebra/core/tags.hpp>
+#include <boost/geometry/extensions/algebra/geometries/concepts/matrix_concept.hpp>
+
+namespace boost { namespace geometry {
+
+namespace model {
+
+template <typename T, std::size_t Rows, std::size_t Cols>
+class matrix
+{
+    BOOST_CONCEPT_ASSERT( (concept::Matrix<matrix>) );
+
+public:
+
+    /// @brief Default constructor, no initialization
+    inline matrix()
+    {}
+
+    /// @brief Get a coordinate
+    /// @tparam I row index
+    /// @tparam J col index
+    /// @return the cell value
+    template <std::size_t I, std::size_t J>
+    inline T const& get() const
+    {
+        BOOST_STATIC_ASSERT(I < Rows);
+        BOOST_STATIC_ASSERT(J < Cols);
+        return m_values[I + Rows * J];
+    }
+
+    /// @brief Set a coordinate
+    /// @tparam I row index
+    /// @tparam J col index
+    /// @param value value to set
+    template <std::size_t I, std::size_t J>
+    inline void set(T const& value)
+    {
+        BOOST_STATIC_ASSERT(I < Rows);
+        BOOST_STATIC_ASSERT(J < Cols);
+        m_values[I + Rows * J] = value;
+    }
+
+private:
+
+    T m_values[Rows * Cols];
+};
+
+} // namespace model
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename CoordinateType, std::size_t Rows, std::size_t Cols>
+struct tag<model::matrix<CoordinateType, Rows, Cols> >
+{
+    typedef matrix_tag type;
+};
+
+template <typename CoordinateType, std::size_t Rows, std::size_t Cols>
+struct coordinate_type<model::matrix<CoordinateType, Rows, Cols> >
+{
+    typedef CoordinateType type;
+};
+
+//template <typename CoordinateType, std::size_t Rows, std::size_t Cols>
+//struct coordinate_system<model::matrix<CoordinateType, Rows, Cols> >
+//{
+//    typedef cs::cartesian type;
+//};
+
+// TODO - move this class to traits.hpp
+template <typename Geometry, std::size_t Index>
+struct indexed_dimension
+{
+     BOOST_MPL_ASSERT_MSG(false,
+                          NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_OR_INDEX,
+                          (Geometry, boost::integral_constant<std::size_t, Index>));
+};
+
+template <typename CoordinateType, std::size_t Rows, std::size_t Cols>
+struct indexed_dimension<model::matrix<CoordinateType, Rows, Cols>, 0>
+    : boost::integral_constant<std::size_t, Rows>
+{};
+
+template <typename CoordinateType, std::size_t Rows, std::size_t Cols>
+struct indexed_dimension<model::matrix<CoordinateType, Rows, Cols>, 1>
+    : boost::integral_constant<std::size_t, Cols>
+{};
+
+template <typename CoordinateType, std::size_t Rows, std::size_t Cols, std::size_t I, std::size_t J>
+struct indexed_access<model::matrix<CoordinateType, Dimension>, I, J>
+{
+    typedef CoordinateType coordinate_type;
+
+    static inline coordinate_type get(model::matrix<CoordinateType, Rows, Cols> const& m)
+    {
+        return m.template get<I, J>();
+    }
+
+    static inline void set(model::matrix<CoordinateType, Rows, Cols> & m, coordinate_type const& value)
+    {
+        m.template set<I, J>(value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_MATRIX_HPP
Added: trunk/boost/geometry/extensions/algebra/geometries/quaternion.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/geometry/extensions/algebra/geometries/quaternion.hpp	2013-06-21 15:30:38 EDT (Fri, 21 Jun 2013)	(r84868)
@@ -0,0 +1,130 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_QUATERNION_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_QUATERNION_HPP
+
+#include <cstddef>
+
+#include <boost/geometry/extensions/algebra/core/tags.hpp>
+#include <boost/geometry/extensions/algebra/geometries/concepts/quaternion_concept.hpp>
+
+// WARNING!
+// It is probable that the sequence of coordinate will change in the future
+// at the beginning there would be xyz, w would become the last coordinate
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+template <typename T>
+class quaternion
+{
+    BOOST_CONCEPT_ASSERT( (concept::Quaternion<quaternion>) );
+
+public:
+
+    /// @brief Default constructor, no initialization
+    inline quaternion()
+    {}
+
+    /// @brief Constructor to set components
+    inline quaternion(T const& w, T const& x, T const& y, T const& z)
+    {
+        m_values[0] = w;
+        m_values[1] = x;
+        m_values[2] = y;
+        m_values[3] = z;
+    }
+
+    /// @brief Get a coordinate
+    /// @tparam K coordinate to get
+    /// @return the coordinate
+    template <std::size_t K>
+    inline T const& get() const
+    {
+        BOOST_STATIC_ASSERT(K < 4);
+        return m_values[K];
+    }
+
+    /// @brief Set a coordinate
+    /// @tparam K coordinate to set
+    /// @param value value to set
+    template <std::size_t K>
+    inline void set(T const& value)
+    {
+        BOOST_STATIC_ASSERT(K < 4);
+        m_values[K] = value;
+    }
+
+private:
+
+    T m_values[4];
+};
+
+
+} // namespace model
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename CoordinateType>
+struct tag<model::quaternion<CoordinateType> >
+{
+    typedef quaternion_tag type;
+};
+
+template <typename CoordinateType>
+struct coordinate_type<model::quaternion<CoordinateType> >
+{
+    typedef CoordinateType type;
+};
+
+//template <typename CoordinateType>
+//struct coordinate_system<model::quaternion<CoordinateType> >
+//{
+//    typedef cs::cartesian type;
+//};
+
+template <typename CoordinateType>
+struct dimension<model::quaternion<CoordinateType> >
+    : boost::integral_constant<std::size_t, 4>
+{};
+
+template<typename CoordinateType, std::size_t Dimension>
+struct access<model::quaternion<CoordinateType>, Dimension>
+{
+    static inline CoordinateType get(
+        model::quaternion<CoordinateType> const& v)
+    {
+        return v.template get<Dimension>();
+    }
+
+    static inline void set(
+        model::quaternion<CoordinateType> & v,
+        CoordinateType const& value)
+    {
+        v.template set<Dimension>(value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_GEOMETRIES_QUATERNION_HPP