b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
7fd59977 |
14 | |
15 | inline gp_Lin2d::gp_Lin2d () |
16 | { } |
17 | |
18 | inline gp_Lin2d::gp_Lin2d (const gp_Ax2d& A) : pos(A) |
19 | { } |
20 | |
21 | inline gp_Lin2d::gp_Lin2d (const gp_Pnt2d& P, |
22 | const gp_Dir2d& V) : pos(P, V) |
23 | { } |
24 | |
25 | inline void gp_Lin2d::Reverse() |
26 | { pos.Reverse(); } |
27 | |
28 | inline gp_Lin2d gp_Lin2d::Reversed() const |
29 | { |
30 | gp_Lin2d L = *this; |
31 | L.pos.Reverse (); |
32 | return L; |
33 | } |
34 | |
35 | inline void gp_Lin2d::SetDirection (const gp_Dir2d& V) |
36 | { pos.SetDirection (V); } |
37 | |
38 | inline void gp_Lin2d::SetLocation (const gp_Pnt2d& P) |
39 | { pos.SetLocation (P); } |
40 | |
41 | inline void gp_Lin2d::SetPosition (const gp_Ax2d& A) |
42 | { pos = A; } |
43 | |
44 | inline void gp_Lin2d::Coefficients (Standard_Real& A, |
45 | Standard_Real& B, |
46 | Standard_Real& C) const |
47 | { |
48 | A = pos.Direction().Y(); |
49 | B = - pos.Direction().X(); |
50 | C = -(A * pos.Location().X() + B * pos.Location().Y()); |
51 | } |
52 | |
53 | inline const gp_Dir2d& gp_Lin2d::Direction() const |
54 | { return pos.Direction(); } |
55 | |
56 | inline const gp_Pnt2d& gp_Lin2d::Location() const |
57 | { return pos.Location(); } |
58 | |
59 | inline const gp_Ax2d& gp_Lin2d::Position() const |
60 | { return pos; } |
61 | |
62 | inline Standard_Real gp_Lin2d::Angle (const gp_Lin2d& Other) const |
63 | { return pos.Direction().Angle (Other.pos.Direction()); } |
64 | |
65 | inline Standard_Boolean gp_Lin2d::Contains |
66 | (const gp_Pnt2d& P, |
67 | const Standard_Real LinearTolerance) const |
68 | { return Distance(P) <= LinearTolerance; } |
69 | |
70 | inline Standard_Real gp_Lin2d::Distance (const gp_Pnt2d& P) const |
71 | { |
72 | gp_XY Coord = P.XY(); |
73 | Coord.Subtract ((pos.Location()).XY()); |
74 | Standard_Real val = Coord.Crossed (pos.Direction().XY()); |
75 | if (val < 0) val = - val; |
76 | return val; |
77 | } |
78 | |
79 | inline Standard_Real gp_Lin2d::Distance (const gp_Lin2d& Other) const |
80 | { |
81 | Standard_Real D = 0.0; |
82 | if (pos.IsParallel (Other.pos, gp::Resolution())) |
83 | D = Other.Distance(pos.Location()); |
84 | return D; |
85 | } |
86 | |
87 | inline Standard_Real gp_Lin2d::SquareDistance (const gp_Pnt2d& P) const |
88 | { |
89 | gp_XY Coord = P.XY(); |
90 | Coord.Subtract ((pos.Location()).XY()); |
91 | Standard_Real D = Coord.Crossed (pos.Direction().XY()); |
92 | return D * D; |
93 | } |
94 | |
95 | inline Standard_Real gp_Lin2d::SquareDistance (const gp_Lin2d& Other) const |
96 | { |
97 | Standard_Real D = 0.0; |
d4b867e6 |
98 | if (pos.IsParallel (Other.pos, gp::Resolution())) |
99 | D = Other.SquareDistance(pos.Location()); |
7fd59977 |
100 | return D; |
101 | } |
102 | |
103 | inline gp_Lin2d gp_Lin2d::Normal (const gp_Pnt2d& P) const |
104 | { |
105 | return gp_Lin2d |
106 | (gp_Ax2d |
107 | (P,gp_Dir2d |
108 | (-(pos.Direction().Y()), pos.Direction().X()))); |
109 | } |
110 | |
111 | inline void gp_Lin2d::Rotate (const gp_Pnt2d& P, const Standard_Real Ang) |
112 | { pos.Rotate (P, Ang); } |
113 | |
114 | inline gp_Lin2d gp_Lin2d::Rotated (const gp_Pnt2d& P, |
115 | const Standard_Real Ang) const |
116 | { |
117 | gp_Lin2d L = *this; |
118 | L.pos.Rotate (P, Ang); |
119 | return L; |
120 | } |
121 | |
122 | inline void gp_Lin2d::Scale (const gp_Pnt2d& P, const Standard_Real S) |
123 | { pos.Scale(P, S); } |
124 | |
125 | inline gp_Lin2d gp_Lin2d::Scaled (const gp_Pnt2d& P, |
126 | const Standard_Real S) const |
127 | { |
128 | gp_Lin2d L = *this; |
129 | L.pos.Scale(P, S); |
130 | return L; |
131 | } |
132 | |
133 | inline void gp_Lin2d::Transform (const gp_Trsf2d& T) |
134 | { pos.Transform(T); } |
135 | |
136 | inline gp_Lin2d gp_Lin2d::Transformed (const gp_Trsf2d& T) const |
137 | { |
138 | gp_Lin2d L = *this; |
139 | L.pos.Transform(T); |
140 | return L; |
141 | } |
142 | |
143 | inline void gp_Lin2d::Translate (const gp_Vec2d& V) |
144 | { pos.Translate(V); } |
145 | |
146 | inline gp_Lin2d gp_Lin2d::Translated (const gp_Vec2d& V) const |
147 | { |
148 | gp_Lin2d L = *this; |
149 | L.pos.Translate(V); |
150 | return L; |
151 | } |
152 | |
153 | inline void gp_Lin2d::Translate (const gp_Pnt2d& P1, |
154 | const gp_Pnt2d& P2) |
155 | { pos.Translate(P1, P2); } |
156 | |
157 | inline gp_Lin2d gp_Lin2d::Translated (const gp_Pnt2d& P1, |
158 | const gp_Pnt2d& P2) const |
159 | { |
160 | gp_Lin2d L = *this; |
161 | L.pos.Translate (gp_Vec2d(P1, P2)); |
162 | return L; |
163 | } |
164 | |