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. |
b311480e |
14 | |
7fd59977 |
15 | // JCV 10/01/91 modifs suite a la deuxieme revue de projet |
16 | // AGV 03/04/07 bug correction: "pos" origin too far when A is very small |
17 | |
18 | #define No_Standard_OutOfRange |
19 | |
d5477f8c |
20 | #include <gp_Lin2d.hxx> |
42cf5bc1 |
21 | |
7fd59977 |
22 | #include <gp.hxx> |
42cf5bc1 |
23 | #include <gp_Ax2d.hxx> |
24 | #include <gp_Dir2d.hxx> |
42cf5bc1 |
25 | #include <gp_Pnt2d.hxx> |
26 | #include <gp_Trsf2d.hxx> |
42cf5bc1 |
27 | #include <Standard_ConstructionError.hxx> |
7fd59977 |
28 | |
29 | //======================================================================= |
30 | //function : gp_Lin2d |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | gp_Lin2d::gp_Lin2d (const Standard_Real A, |
34 | const Standard_Real B, |
35 | const Standard_Real C) |
36 | { |
37 | const Standard_Real Norm2 = A * A + B * B; |
38 | Standard_ConstructionError_Raise_if (Norm2 <= gp::Resolution(), " "); |
39 | const gp_Pnt2d P (-A*C/Norm2, -B*C/Norm2); |
40 | const gp_Dir2d V (-B, A); |
41 | |
42 | // gp_Pnt2d P; |
43 | // Standard_Real Norm = sqrt(A * A + B * B); |
44 | // Standard_ConstructionError_Raise_if (Norm <= gp::Resolution(), " "); |
45 | // Standard_Real A1 = A/Norm; |
46 | // Standard_Real B1 = B/Norm; |
47 | // Standard_Real C1 = C/Norm; |
48 | // gp_Dir2d V = gp_Dir2d (-B1, A1); |
49 | // Standard_Real AA1 = A1; |
50 | // if (AA1 < 0) AA1 = - AA1; |
51 | // if (AA1 > gp::Resolution()) P.SetCoord (-C1 / A1, 0.0); |
52 | // else P.SetCoord (0.0, -C1 / B1); |
53 | |
54 | pos = gp_Ax2d(P, V); |
55 | } |
56 | |
57 | //======================================================================= |
58 | //function : Mirror |
59 | //purpose : |
60 | //======================================================================= |
61 | |
62 | void gp_Lin2d::Mirror (const gp_Pnt2d& P) |
63 | { pos.Mirror(P); } |
64 | |
65 | //======================================================================= |
66 | //function : Mirrored |
67 | //purpose : |
68 | //======================================================================= |
69 | |
70 | gp_Lin2d gp_Lin2d::Mirrored (const gp_Pnt2d& P) const |
71 | { |
72 | gp_Lin2d L = *this; |
73 | L.pos.Mirror(P); |
74 | return L; |
75 | } |
76 | |
77 | //======================================================================= |
78 | //function : Mirror |
79 | //purpose : |
80 | //======================================================================= |
81 | |
82 | void gp_Lin2d::Mirror (const gp_Ax2d& A) |
83 | { pos.Mirror(A); } |
84 | |
85 | //======================================================================= |
86 | //function : Mirrored |
87 | //purpose : |
88 | //======================================================================= |
89 | |
90 | gp_Lin2d gp_Lin2d::Mirrored (const gp_Ax2d& A) const |
91 | { |
92 | gp_Lin2d L = *this; |
93 | L.pos.Mirror(A); |
94 | return L; |
95 | } |
96 | |