1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 inline gp_Lin2d::gp_Lin2d ()
18 inline gp_Lin2d::gp_Lin2d (const gp_Ax2d& A) : pos(A)
21 inline gp_Lin2d::gp_Lin2d (const gp_Pnt2d& P,
22 const gp_Dir2d& V) : pos(P, V)
25 inline void gp_Lin2d::Reverse()
28 inline gp_Lin2d gp_Lin2d::Reversed() const
35 inline void gp_Lin2d::SetDirection (const gp_Dir2d& V)
36 { pos.SetDirection (V); }
38 inline void gp_Lin2d::SetLocation (const gp_Pnt2d& P)
39 { pos.SetLocation (P); }
41 inline void gp_Lin2d::SetPosition (const gp_Ax2d& A)
44 inline void gp_Lin2d::Coefficients (Standard_Real& A,
46 Standard_Real& C) const
48 A = pos.Direction().Y();
49 B = - pos.Direction().X();
50 C = -(A * pos.Location().X() + B * pos.Location().Y());
53 inline const gp_Dir2d& gp_Lin2d::Direction() const
54 { return pos.Direction(); }
56 inline const gp_Pnt2d& gp_Lin2d::Location() const
57 { return pos.Location(); }
59 inline const gp_Ax2d& gp_Lin2d::Position() const
62 inline Standard_Real gp_Lin2d::Angle (const gp_Lin2d& Other) const
63 { return pos.Direction().Angle (Other.pos.Direction()); }
65 inline Standard_Boolean gp_Lin2d::Contains
67 const Standard_Real LinearTolerance) const
68 { return Distance(P) <= LinearTolerance; }
70 inline Standard_Real gp_Lin2d::Distance (const gp_Pnt2d& P) const
73 Coord.Subtract ((pos.Location()).XY());
74 Standard_Real val = Coord.Crossed (pos.Direction().XY());
75 if (val < 0) val = - val;
79 inline Standard_Real gp_Lin2d::Distance (const gp_Lin2d& Other) const
81 Standard_Real D = 0.0;
82 if (pos.IsParallel (Other.pos, gp::Resolution()))
83 D = Other.Distance(pos.Location());
87 inline Standard_Real gp_Lin2d::SquareDistance (const gp_Pnt2d& P) const
90 Coord.Subtract ((pos.Location()).XY());
91 Standard_Real D = Coord.Crossed (pos.Direction().XY());
95 inline Standard_Real gp_Lin2d::SquareDistance (const gp_Lin2d& Other) const
97 Standard_Real D = 0.0;
98 if (pos.IsParallel (Other.pos, gp::Resolution()))
99 D = Other.SquareDistance(pos.Location());
103 inline gp_Lin2d gp_Lin2d::Normal (const gp_Pnt2d& P) const
108 (-(pos.Direction().Y()), pos.Direction().X())));
111 inline void gp_Lin2d::Rotate (const gp_Pnt2d& P, const Standard_Real Ang)
112 { pos.Rotate (P, Ang); }
114 inline gp_Lin2d gp_Lin2d::Rotated (const gp_Pnt2d& P,
115 const Standard_Real Ang) const
118 L.pos.Rotate (P, Ang);
122 inline void gp_Lin2d::Scale (const gp_Pnt2d& P, const Standard_Real S)
125 inline gp_Lin2d gp_Lin2d::Scaled (const gp_Pnt2d& P,
126 const Standard_Real S) const
133 inline void gp_Lin2d::Transform (const gp_Trsf2d& T)
134 { pos.Transform(T); }
136 inline gp_Lin2d gp_Lin2d::Transformed (const gp_Trsf2d& T) const
143 inline void gp_Lin2d::Translate (const gp_Vec2d& V)
144 { pos.Translate(V); }
146 inline gp_Lin2d gp_Lin2d::Translated (const gp_Vec2d& V) const
153 inline void gp_Lin2d::Translate (const gp_Pnt2d& P1,
155 { pos.Translate(P1, P2); }
157 inline gp_Lin2d gp_Lin2d::Translated (const gp_Pnt2d& P1,
158 const gp_Pnt2d& P2) const
161 L.pos.Translate (gp_Vec2d(P1, P2));