summaryrefslogtreecommitdiff
path: root/inc/gp_Pnt2d.lxx
blob: 091179e3c8b4518afb632414a205ca856376cd6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// File gp_Pnt2d.lxx  , REG 27/10/90
// Modif JCV 08/01/91 modifs suite a la deuxieme revue de projet
// et introduction des classes XY, Mat2d.
// Modif DPF 23/06/93 Ajout fonction Coord pour genericite 2d 3d

#include <gp_Vec2d.hxx>
#include <gp_Ax2d.hxx>
#include <gp_Trsf2d.hxx>

inline gp_Pnt2d::gp_Pnt2d (const gp_XY& Coordinates) : coord (Coordinates)
{ }

inline gp_Pnt2d::gp_Pnt2d (const Standard_Real Xp,
			   const Standard_Real Yp) : coord (Xp, Yp)
{ }

inline gp_Pnt2d::gp_Pnt2d() { }

inline Standard_Real gp_Pnt2d::Coord(const Standard_Integer Index) const { return coord.Coord(Index); }

inline void gp_Pnt2d::SetX  (const Standard_Real X)
{   coord.SetX (X); }

inline void gp_Pnt2d::SetY  (const Standard_Real Y)
{   coord.SetY (Y); }

inline void gp_Pnt2d::SetXY (const gp_XY& Coordinates)
{   coord = Coordinates; }

inline void gp_Pnt2d::SetCoord (const Standard_Real Xp,
				const Standard_Real Yp)
{  coord.SetCoord (Xp, Yp);}

inline void gp_Pnt2d::SetCoord (const Standard_Integer Index,
				const Standard_Real Xi)
{ coord.SetCoord (Index, Xi); }

inline void gp_Pnt2d::Coord (Standard_Real& Xp,
			     Standard_Real& Yp) const
{ coord.Coord (Xp, Yp); }

inline Standard_Real gp_Pnt2d::X() const
{ return coord.X(); }

inline Standard_Real gp_Pnt2d::Y() const
{ return coord.Y(); }

inline const gp_XY& gp_Pnt2d::XY () const
{ return coord; }

inline const gp_XY& gp_Pnt2d::Coord () const
{ return coord; }

inline  gp_XY& gp_Pnt2d::ChangeCoord ()
{ return coord; }

inline Standard_Boolean gp_Pnt2d::IsEqual
(const gp_Pnt2d& Other,
 const Standard_Real LinearTolerance) const
{ return Distance (Other) <= LinearTolerance; }

inline Standard_Real gp_Pnt2d::Distance (const gp_Pnt2d& Other) const
{
  const gp_XY& XY = Other.coord;
  Standard_Real X = coord.X() - XY.X();
  Standard_Real Y = coord.Y() - XY.Y();
  return sqrt (X * X + Y * Y);
}

inline Standard_Real gp_Pnt2d::SquareDistance (const gp_Pnt2d& Other) const
{
  const gp_XY& XY = Other.coord;
  Standard_Real X = coord.X() - XY.X();
  Standard_Real Y = coord.Y() - XY.Y();
  return (X * X + Y * Y);
}

inline void gp_Pnt2d::Rotate (const gp_Pnt2d& P,
			      const Standard_Real Ang)
{       
  gp_Trsf2d T;
  T.SetRotation (P, Ang);
  T.Transforms  (coord);
}

inline gp_Pnt2d gp_Pnt2d::Rotated (const gp_Pnt2d& P,
				   const Standard_Real Ang) const
{
  gp_Pnt2d Pres = *this;
  Pres.Rotate (P, Ang);
  return Pres;
}

inline void gp_Pnt2d::Scale (const gp_Pnt2d& P,
			     const Standard_Real S)
{
  gp_XY XY = P.coord;
  XY.Multiply (1.0 - S);
  coord.Multiply (S);
  coord.Add      (XY);
}

inline gp_Pnt2d gp_Pnt2d::Scaled (const gp_Pnt2d& P,
				  const Standard_Real S)  const
{
  gp_Pnt2d Pres = *this;
  Pres.Scale (P, S);
  return Pres;
}

inline gp_Pnt2d gp_Pnt2d::Transformed (const gp_Trsf2d& T) const
{
  gp_Pnt2d Pres = *this;
  Pres.Transform (T);
  return Pres;
}

inline void gp_Pnt2d::Translate (const gp_Vec2d& V)
{ coord.Add (V.XY()); }

inline gp_Pnt2d gp_Pnt2d::Translated (const gp_Vec2d& V) const
{
  gp_Pnt2d P = *this;
  P.coord.Add (V.XY ());
  return P;
}

inline void gp_Pnt2d::Translate (const gp_Pnt2d& P1,
				 const gp_Pnt2d& P2)
{
  coord.Add      (P2.coord);
  coord.Subtract (P1.coord);
}               

inline gp_Pnt2d gp_Pnt2d::Translated (const gp_Pnt2d& P1,
				      const gp_Pnt2d& P2) const
{
  gp_Pnt2d P = *this;
  P.Translate (P1, P2);
  return P;
}