plane: add trivial plane type

This commit is contained in:
Danny Robson 2015-02-19 13:28:36 +11:00
parent c8f067bf60
commit ae6745a66a
3 changed files with 81 additions and 0 deletions

View File

@ -113,6 +113,8 @@ UTIL_FILES = \
options.hpp \
pascal.cpp \
pascal.hpp \
plane.cpp \
plane.hpp \
platform.hpp \
point.cpp \
point.hpp \

38
plane.cpp Normal file
View File

@ -0,0 +1,38 @@
/*
* This file is part of libgim.
*
* libgim is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
*/
#include "plane.hpp"
#include "debug.hpp"
//-----------------------------------------------------------------------------
template <size_t S, typename T>
util::plane<S,T>::plane (util::point<S,T> _p,
util::vector<S,T> _n):
p (_p),
n (_n)
{
CHECK_EQ (n.magnitude2 (), 1);
}
//-----------------------------------------------------------------------------
template struct util::plane<2,float>;
template struct util::plane<3,float>;

41
plane.hpp Normal file
View File

@ -0,0 +1,41 @@
/*
* This file is part of libgim.
*
* libgim is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
*/
#ifndef __UTIL_PLANE_HPP
#define __UTIL_PLANE_HPP
#include "point.hpp"
#include "vector.hpp"
namespace util {
template <size_t S, typename T>
struct plane {
plane (util::point<S,T> p,
util::vector<S,T> n);
util::point<S,T> p;
util::vector<S,T> n;
};
typedef plane<2,float> plane2f;
typedef plane<3,float> plane3f;
}
#endif