OpenLexocad  27.1
Pnt2d.h
Go to the documentation of this file.
1 //
3 // Copyright(C) 2013-2016 OpenCascade [www.opencascade.org]
4 //
5 // This library is free software; you can redistribute it and / or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street,
18 // Fifth Floor, Boston, MA 02110 - 1301 USA
19 //
21 
22 #pragma once
23 
24 #include <Geom/XY.h>
25 
26 namespace Geom
27 {
28 class Ax2d;
29 class Trsf2d;
30 class Vec2d;
31 
33 class LX_GEOM_EXPORT Pnt2d
34 {
35 public:
36  Pnt2d();
38  Pnt2d(const XY& Coord);
39 
41  Pnt2d(const double Xp, const double Yp);
42 
45  XY& changeCoord();
47  const XY& coord() const;
48 
53  double coord(const int Index) const;
55  void coord(double& Xp, double& Yp) const;
57  double distance(const Pnt2d& Other) const;
61  bool isEqual(const Pnt2d& Other, const double LinearTolerance) const;
65  void mirror(const Pnt2d& P);
66 
69  Pnt2d mirrored(const Pnt2d& P) const;
70 
71  void mirror(const Ax2d& A);
72 
75  Pnt2d mirrored(const Ax2d& A) const;
76 
77  void rotate(const Pnt2d& P, const double Ang);
79  Pnt2d rotated(const Pnt2d& P, const double Ang) const;
80 
81  void scale(const Pnt2d& P, const double S);
83  Pnt2d scaled(const Pnt2d& P, const double S) const;
84 
89  void setCoord(const int Index, const double Xi);
91  void setCoord(const double Xp, const double Yp);
93  void setX(const double X);
95  void setXY(const XY& Coord);
96 
98  void setY(const double Y);
100  double squareDistance(const Pnt2d& Other) const;
101 
102  void transform(const Trsf2d& T);
103  //
106  Pnt2d transformed(const Trsf2d& T) const;
107 
108  void translate(const Vec2d& V);
109  //
111  Pnt2d translated(const Vec2d& V) const;
112 
113  void translate(const Pnt2d& P1, const Pnt2d& P2);
114 
115  Pnt2d translated(const Pnt2d& P1, const Pnt2d& P2) const;
116 
118  double x() const;
120  const XY& xy() const;
122  double y() const;
123 
125  bool operator==(const Geom::Pnt2d& other) const;
127  bool operator!=(const Geom::Pnt2d& other) const;
128 
129 protected:
130 private:
131  XY _coord;
132 };
133 
134 } // namespace Geom
Definition: Variant.h:60
X
Definition: Globals.h:29
Definition: XY.h:33
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) ENTT_NOEXCEPT
Compares two hashed strings.
Definition: entt.hpp:570
Definition: Ax2d.h:48
void transform(Container container, OutputIt out, BinaryFunction function)
Definition: Algorithms.h:29
Y
Definition: Globals.h:29
Defines a non-persistent vector in 2D space.
Definition: Vec2d.h:34
Definition: Trsf2d.h:46
double distance(const Geom::Vec &v1, const Geom::Vec &v2)
Returns the distance between two points.
Definition: Vec.h:345
Defines a non-persistent 2D cartesian point.
Definition: Pnt2d.h:33