MEPP2 Project
Geometry_traits_operators.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 #include <iostream> // due to some std::cout
14 
15 namespace FEVV {
16 namespace GeometryTraits {
17 
21 template< typename GeometryTraits >
23 add_v(const typename GeometryTraits::Vector &v1,
24  const typename GeometryTraits::Vector &v2)
25 {
26  typedef typename GeometryTraits::Vector Vector;
27  Vector result(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]);
28  return result;
29 }
30 
34 template< typename GeometryTraits >
35 typename GeometryTraits::Point
36 add_pv(const typename GeometryTraits::Point &p,
37  const typename GeometryTraits::Vector &v)
38 {
39  typedef typename GeometryTraits::Point Point;
40  Point result(p[0] + v[0], p[1] + v[1], p[2] + v[2]);
41  return result;
42 }
43 
47 template< typename GeometryTraits >
48 typename GeometryTraits::Point
49 sub_pv(const typename GeometryTraits::Point &p,
50  const typename GeometryTraits::Vector &v)
51 {
52  typedef typename GeometryTraits::Point Point;
53  Point result(p[0] - v[0], p[1] - v[1], p[2] - v[2]);
54  return result;
55 }
56 
60 template< typename GeometryTraits >
62 sub_p(const typename GeometryTraits::Point &p1,
63  const typename GeometryTraits::Point &p2)
64 {
65  typedef typename GeometryTraits::Vector Vector;
66  Vector result(p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]);
67  return result;
68 }
69 
73 template< typename GeometryTraits >
75 sub_v(const typename GeometryTraits::Vector &v1,
76  const typename GeometryTraits::Vector &v2)
77 {
78  typedef typename GeometryTraits::Vector Vector;
79  Vector result(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]);
80  return result;
81 }
82 
86 template< typename GeometryTraits >
87 typename GeometryTraits::Scalar
89  const typename GeometryTraits::Vector &v2)
90 {
91  return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
92 }
93 
94 } // namespace GeometryTraits
95 } // namespace FEVV
96 
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::GeometryTraits::sub_p
GeometryTraits::Vector sub_p(const typename GeometryTraits::Point &p1, const typename GeometryTraits::Point &p2)
Returns point P1 minus point P2.
Definition: Geometry_traits_operators.h:62
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
FEVV::GeometryTraits::sub_pv
GeometryTraits::Point sub_pv(const typename GeometryTraits::Point &p, const typename GeometryTraits::Vector &v)
Returns point P minus vector V.
Definition: Geometry_traits_operators.h:49
FEVV::GeometryTraits::dot_product
GeometryTraits::Scalar dot_product(const typename GeometryTraits::Vector &v1, const typename GeometryTraits::Vector &v2)
Returns the dot product of vectors V1 and V2.
Definition: Geometry_traits_operators.h:88
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::GeometryTraits::sub_v
GeometryTraits::Vector sub_v(const typename GeometryTraits::Vector &v1, const typename GeometryTraits::Vector &v2)
Returns vector V1 minus vector V2.
Definition: Geometry_traits_operators.h:75
FEVV::GeometryTraits::add_pv
GeometryTraits::Point add_pv(const typename GeometryTraits::Point &p, const typename GeometryTraits::Vector &v)
Returns the sum of point P and vector V.
Definition: Geometry_traits_operators.h:36
FEVV::GeometryTraits::add_v
GeometryTraits::Vector add_v(const typename GeometryTraits::Vector &v1, const typename GeometryTraits::Vector &v2)
Returns the sum of vectors V1 and V2.
Definition: Geometry_traits_operators.h:23
FEVV::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31