1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
21 inline gp_Lin2d::gp_Lin2d ()
24 inline gp_Lin2d::gp_Lin2d (const gp_Ax2d& A) : pos(A)
27 inline gp_Lin2d::gp_Lin2d (const gp_Pnt2d& P,
28 const gp_Dir2d& V) : pos(P, V)
31 inline void gp_Lin2d::Reverse()
34 inline gp_Lin2d gp_Lin2d::Reversed() const
41 inline void gp_Lin2d::SetDirection (const gp_Dir2d& V)
42 { pos.SetDirection (V); }
44 inline void gp_Lin2d::SetLocation (const gp_Pnt2d& P)
45 { pos.SetLocation (P); }
47 inline void gp_Lin2d::SetPosition (const gp_Ax2d& A)
50 inline void gp_Lin2d::Coefficients (Standard_Real& A,
52 Standard_Real& C) const
54 A = pos.Direction().Y();
55 B = - pos.Direction().X();
56 C = -(A * pos.Location().X() + B * pos.Location().Y());
59 inline const gp_Dir2d& gp_Lin2d::Direction() const
60 { return pos.Direction(); }
62 inline const gp_Pnt2d& gp_Lin2d::Location() const
63 { return pos.Location(); }
65 inline const gp_Ax2d& gp_Lin2d::Position() const
68 inline Standard_Real gp_Lin2d::Angle (const gp_Lin2d& Other) const
69 { return pos.Direction().Angle (Other.pos.Direction()); }
71 inline Standard_Boolean gp_Lin2d::Contains
73 const Standard_Real LinearTolerance) const
74 { return Distance(P) <= LinearTolerance; }
76 inline Standard_Real gp_Lin2d::Distance (const gp_Pnt2d& P) const
79 Coord.Subtract ((pos.Location()).XY());
80 Standard_Real val = Coord.Crossed (pos.Direction().XY());
81 if (val < 0) val = - val;
85 inline Standard_Real gp_Lin2d::Distance (const gp_Lin2d& Other) const
87 Standard_Real D = 0.0;
88 if (pos.IsParallel (Other.pos, gp::Resolution()))
89 D = Other.Distance(pos.Location());
93 inline Standard_Real gp_Lin2d::SquareDistance (const gp_Pnt2d& P) const
96 Coord.Subtract ((pos.Location()).XY());
97 Standard_Real D = Coord.Crossed (pos.Direction().XY());
101 inline Standard_Real gp_Lin2d::SquareDistance (const gp_Lin2d& Other) const
103 Standard_Real D = 0.0;
104 if (pos.IsParallel (Other.pos, gp::Resolution())) {
105 D = Other.Distance(pos.Location());
111 inline gp_Lin2d gp_Lin2d::Normal (const gp_Pnt2d& P) const
116 (-(pos.Direction().Y()), pos.Direction().X())));
119 inline void gp_Lin2d::Rotate (const gp_Pnt2d& P, const Standard_Real Ang)
120 { pos.Rotate (P, Ang); }
122 inline gp_Lin2d gp_Lin2d::Rotated (const gp_Pnt2d& P,
123 const Standard_Real Ang) const
126 L.pos.Rotate (P, Ang);
130 inline void gp_Lin2d::Scale (const gp_Pnt2d& P, const Standard_Real S)
133 inline gp_Lin2d gp_Lin2d::Scaled (const gp_Pnt2d& P,
134 const Standard_Real S) const
141 inline void gp_Lin2d::Transform (const gp_Trsf2d& T)
142 { pos.Transform(T); }
144 inline gp_Lin2d gp_Lin2d::Transformed (const gp_Trsf2d& T) const
151 inline void gp_Lin2d::Translate (const gp_Vec2d& V)
152 { pos.Translate(V); }
154 inline gp_Lin2d gp_Lin2d::Translated (const gp_Vec2d& V) const
161 inline void gp_Lin2d::Translate (const gp_Pnt2d& P1,
163 { pos.Translate(P1, P2); }
165 inline gp_Lin2d gp_Lin2d::Translated (const gp_Pnt2d& P1,
166 const gp_Pnt2d& P2) const
169 L.pos.Translate (gp_Vec2d(P1, P2));