KiCad PCB EDA Suite
4pt_polygon_2d.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 (C) 2015-2016 Mario Luzeiro <[email protected]>
5  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef _POLYGON_4PT_2D_H_
31 #define _POLYGON_4PT_2D_H_
32 
33 #include "object_2d.h"
34 
41 class POLYGON_4PT_2D : public OBJECT_2D
42 {
43 public:
44  POLYGON_4PT_2D( const SFVEC2F& v1, const SFVEC2F& v2, const SFVEC2F& v3, const SFVEC2F& v4,
45  const BOARD_ITEM& aBoardItem );
46 
47  const SFVEC2F& GetV0() const { return m_segments[0]; }
48  const SFVEC2F& GetV1() const { return m_segments[1]; }
49  const SFVEC2F& GetV2() const { return m_segments[2]; }
50  const SFVEC2F& GetV3() const { return m_segments[3]; }
51 
52  const SFVEC2F& GetN0() const { return m_seg_normal[0]; }
53  const SFVEC2F& GetN1() const { return m_seg_normal[1]; }
54  const SFVEC2F& GetN2() const { return m_seg_normal[2]; }
55  const SFVEC2F& GetN3() const { return m_seg_normal[3]; }
56 
57  bool Overlaps( const BBOX_2D& aBBox ) const override;
58  bool Intersects( const BBOX_2D& aBBox ) const override;
59  bool Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const override;
60  INTERSECTION_RESULT IsBBoxInside( const BBOX_2D& aBBox ) const override;
61  bool IsPointInside( const SFVEC2F& aPoint ) const override;
62 
63 private:
67 };
68 
69 
70 #endif // _POLYGON_4PT_2D_H_
SFVEC2F m_segments[4]
const SFVEC2F & GetV1() const
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
INTERSECTION_RESULT IsBBoxInside(const BBOX_2D &aBBox) const override
Test this object if it's completely outside, intersects, or is completely inside aBBox.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
SFVEC2F m_precalc_slope[4]
const SFVEC2F & GetN3() const
const SFVEC2F & GetV2() const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
INTERSECTION_RESULT
Definition: object_2d.h:36
bool Intersects(const BBOX_2D &aBBox) const override
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
bool IsPointInside(const SFVEC2F &aPoint) const override
Manage a bounding box defined by two SFVEC2F min max points.
Definition: bbox_2d.h:41
Simple non-intersecting polygon with 4 points.
const SFVEC2F & GetN1() const
const SFVEC2F & GetN2() const
const SFVEC2F & GetV3() const
POLYGON_4PT_2D(const SFVEC2F &v1, const SFVEC2F &v2, const SFVEC2F &v3, const SFVEC2F &v4, const BOARD_ITEM &aBoardItem)
SFVEC2F m_seg_normal[4]
const SFVEC2F & GetV0() const
const SFVEC2F & GetN0() const
bool Overlaps(const BBOX_2D &aBBox) const override
Test if the box overlaps the object.
Definition: ray.h:105