KiCad PCB EDA Suite
hetraits.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
3  * Applied Mathematics, Norway.
4  *
5  * Contact information: E-mail: tor.dokken@sintef.no
6  * SINTEF ICT, Department of Applied Mathematics,
7  * P.O. Box 124 Blindern,
8  * 0314 Oslo, Norway.
9  *
10  * This file is part of TTL.
11  *
12  * TTL is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Affero General Public License as
14  * published by the Free Software Foundation, either version 3 of the
15  * License, or (at your option) any later version.
16  *
17  * TTL is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Affero General Public License for more details.
21  *
22  * You should have received a copy of the GNU Affero General Public
23  * License along with TTL. If not, see
24  * <http://www.gnu.org/licenses/>.
25  *
26  * In accordance with Section 7(b) of the GNU Affero General Public
27  * License, a covered work must retain the producer line in every data
28  * file that is created or manipulated using TTL.
29  *
30  * Other Usage
31  * You can be released from the requirements of the license by purchasing
32  * a commercial license. Buying such a license is mandatory as soon as you
33  * develop commercial activities involving the TTL library without
34  * disclosing the source code of your own applications.
35  *
36  * This file may be used in accordance with the terms contained in a
37  * written agreement between you and SINTEF ICT.
38  */
39 
40 #ifndef _HALF_EDGE_TRAITS_
41 #define _HALF_EDGE_TRAITS_
42 
43 #include <ttl/halfedge/hetriang.h>
44 #include <ttl/halfedge/hedart.h>
45 
46 namespace hed
47 {
62 struct TTLtraits
63 {
67  typedef double REAL_TYPE;
68 
76  static REAL_TYPE ScalarProduct2D( const DART& aV1, const DART& aV2 )
77  {
78  DART v10 = aV1;
79  v10.Alpha0();
80 
81  DART v20 = aV2;
82  v20.Alpha0();
83 
84  return ttl_util::ScalarProduct2D( v10.X() - aV1.X(), v10.Y() - aV1.Y(),
85  v20.X() - aV2.X(), v20.Y() - aV2.Y() );
86  }
87 
95  static REAL_TYPE ScalarProduct2D( const DART& aV, const NODE_PTR& aP )
96  {
97  DART d0 = aV;
98  d0.Alpha0();
99 
100  return ttl_util::ScalarProduct2D( d0.X() - aV.X(), d0.Y() - aV.Y(),
101  aP->GetX() - aV.X(), aP->GetY() - aV.Y() );
102  }
103 
110  static REAL_TYPE CrossProduct2D( const DART& aV1, const DART& aV2 )
111  {
112  DART v10 = aV1;
113  v10.Alpha0();
114 
115  DART v20 = aV2;
116  v20.Alpha0();
117 
118  return ttl_util::CrossProduct2D( v10.X() - aV1.X(), v10.Y() - aV1.Y(),
119  v20.X() - aV2.X(), v20.Y() - aV2.Y() );
120  }
121 
130  static REAL_TYPE CrossProduct2D( const DART& aV, const NODE_PTR& aP )
131  {
132  DART d0 = aV;
133  d0.Alpha0();
134 
135  return ttl_util::CrossProduct2D( d0.X() - aV.X(), d0.Y() - aV.Y(),
136  aP->GetX() - aV.X(), aP->GetY() - aV.Y() );
137  }
138 
145  static REAL_TYPE Orient2D( const DART& aN1, const DART& aN2, const NODE_PTR& aP )
146  {
147  REAL_TYPE pa[2];
148  REAL_TYPE pb[2];
149  REAL_TYPE pc[2];
150 
151  pa[0] = aN1.X();
152  pa[1] = aN1.Y();
153  pb[0] = aN2.X();
154  pb[1] = aN2.Y();
155  pc[0] = aP->GetX();
156  pc[1] = aP->GetY();
157 
158  return ttl_util::Orient2DFast( pa, pb, pc );
159  }
160 
168  static REAL_TYPE Orient2D( const DART& aN1, const DART& aN2, const DART& aP )
169  {
170  REAL_TYPE pa[2];
171  REAL_TYPE pb[2];
172  REAL_TYPE pc[2];
173 
174  pa[0] = aN1.X();
175  pa[1] = aN1.Y();
176  pb[0] = aN2.X();
177  pb[1] = aN2.Y();
178  pc[0] = aP.X();
179  pc[1] = aP.Y();
180 
181  return ttl_util::Orient2DFast( pa, pb, pc );
182  }
183 
185 };
186 
187 } // End of hed namespace
188 
189 #endif
static REAL_TYPE Orient2D(const DART &aN1, const DART &aN2, const NODE_PTR &aP)
Let n1 and n2 be the nodes associated with two darts, and let p be a point in the plane...
Definition: hetraits.h:145
Traits class (static struct) for the half-edge data structure.
Definition: hetraits.h:62
static REAL_TYPE ScalarProduct2D(const DART &aV1, const DART &aV2)
Scalar product between two 2D vectors represented as darts.
Definition: hetraits.h:76
static REAL_TYPE Orient2D(const DART &aN1, const DART &aN2, const DART &aP)
This is the same predicate as represented with the function above, but with a slighty different inter...
Definition: hetraits.h:168
double Y() const
Definition: hedart.h:168
double X() const
Definition: hedart.h:163
DART & Alpha0()
Maps the dart to a different node.
Definition: hedart.h:115
static REAL_TYPE ScalarProduct2D(const DART &aV, const NODE_PTR &aP)
Scalar product between two 2D vectors.
Definition: hetraits.h:95
REAL_TYPE ScalarProduct2D(REAL_TYPE aDX1, REAL_TYPE aDY1, REAL_TYPE aDX2, REAL_TYPE aDY2)
Scalar product between two 2D vectors.
Definition: ttl_util.h:89
std::shared_ptr< NODE > NODE_PTR
Definition: hetriang.h:73
REAL_TYPE Orient2DFast(REAL_TYPE aPA[2], REAL_TYPE aPB[2], REAL_TYPE aPC[2])
Returns a positive value if the 2D nodes/points aPA, aPB, and aPC occur in counterclockwise order; a ...
Definition: ttl_util.h:117
The half-edge data structure.
Definition: hedart.h:45
static REAL_TYPE CrossProduct2D(const DART &aV, const NODE_PTR &aP)
Cross product between two vectors in the plane.
Definition: hetraits.h:130
double REAL_TYPE
The floating point type used in calculations involving scalar products and cross products.
Definition: hetraits.h:67
static REAL_TYPE CrossProduct2D(const DART &aV1, const DART &aV2)
Cross product between two vectors in the plane represented as darts.
Definition: hetraits.h:110
REAL_TYPE CrossProduct2D(REAL_TYPE aDX1, REAL_TYPE aDY1, REAL_TYPE aDX2, REAL_TYPE aDY2)
Cross product between two 2D vectors.
Definition: ttl_util.h:102