From ae6745a66a6d5936067e7cb10b63a2f6dd3120d4 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 19 Feb 2015 13:28:36 +1100 Subject: [PATCH] plane: add trivial plane type --- Makefile.am | 2 ++ plane.cpp | 38 ++++++++++++++++++++++++++++++++++++++ plane.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 plane.cpp create mode 100644 plane.hpp diff --git a/Makefile.am b/Makefile.am index dab645ef..ce581deb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -113,6 +113,8 @@ UTIL_FILES = \ options.hpp \ pascal.cpp \ pascal.hpp \ + plane.cpp \ + plane.hpp \ platform.hpp \ point.cpp \ point.hpp \ diff --git a/plane.cpp b/plane.cpp new file mode 100644 index 00000000..3c94c32a --- /dev/null +++ b/plane.cpp @@ -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 . + * + * Copyright 2015 Danny Robson + */ + + +#include "plane.hpp" + +#include "debug.hpp" + +//----------------------------------------------------------------------------- +template +util::plane::plane (util::point _p, + util::vector _n): + p (_p), + n (_n) +{ + CHECK_EQ (n.magnitude2 (), 1); +} + + +//----------------------------------------------------------------------------- +template struct util::plane<2,float>; +template struct util::plane<3,float>; diff --git a/plane.hpp b/plane.hpp new file mode 100644 index 00000000..b5097663 --- /dev/null +++ b/plane.hpp @@ -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 . + * + * Copyright 2015 Danny Robson + */ + +#ifndef __UTIL_PLANE_HPP +#define __UTIL_PLANE_HPP + +#include "point.hpp" +#include "vector.hpp" + +namespace util { + template + struct plane { + plane (util::point p, + util::vector n); + + util::point p; + util::vector n; + }; + + + typedef plane<2,float> plane2f; + typedef plane<3,float> plane3f; +} + +#endif