KiCad PCB EDA Suite
Loading...
Searching...
No Matches
grid_geometry.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef GRID_GEOMETRY_H
21#define GRID_GEOMETRY_H
22
23#include <math/vector2d.h>
24
25
31{
32 enum class KIND
33 {
36 };
37
41 double orientation = 0.0;
44 unsigned priority = 0;
46
52 VECTOR2D Snap( const VECTOR2D& aPoint ) const;
53
57 bool Contains( const VECTOR2D& aPoint, double aTolerance = 0.0 ) const;
58
63 double Area() const;
64
72 bool TakesPrecedenceOver( const GRID_GEOMETRY& aOther ) const
73 {
74 if( priority != aOther.priority )
75 return priority > aOther.priority;
76
77 return Area() < aOther.Area();
78 }
79};
80
81
82#endif
Geometry of a regular grid (cartesian or polar) and the math operations for snapping and coverage tes...
unsigned priority
Higher wins where grids overlap.
double orientation
Rotation about origin, radians CCW.
double Area() const
VECTOR2D extent
Cartesian: (dx, dy) = size/2 from origin.
VECTOR2D pitch
Cartesian: (dx, dy); polar: (dr, dPhi rad).
bool TakesPrecedenceOver(const GRID_GEOMETRY &aOther) const
bool Contains(const VECTOR2D &aPoint, double aTolerance=0.0) const
VECTOR2D Snap(const VECTOR2D &aPoint) const
Snap a point to the nearest on-grid position.
VECTOR2D origin
VECTOR2< double > VECTOR2D
Definition vector2d.h:682