5c06b4725565c0550e8cf44b75b0e3ddcc6985fc
[occt.git] / src / gp / gp_Lin2d.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
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
20
21 #include <gp.hxx>
22 #include <gp_Ax2d.hxx>
23 #include <gp_Dir2d.hxx>
24 #include <gp_Lin2d.hxx>
25 #include <gp_Pnt2d.hxx>
26 #include <gp_Trsf2d.hxx>
27 #include <gp_Vec2d.hxx>
28 #include <Standard_ConstructionError.hxx>
29
30 //=======================================================================
31 //function : gp_Lin2d
32 //purpose  : 
33 //=======================================================================
34 gp_Lin2d::gp_Lin2d (const Standard_Real A,
35                     const Standard_Real B,
36                     const Standard_Real C)
37 {
38   const Standard_Real Norm2 = A * A + B * B;
39   Standard_ConstructionError_Raise_if (Norm2 <= gp::Resolution(), " ");
40   const gp_Pnt2d P (-A*C/Norm2, -B*C/Norm2);
41   const gp_Dir2d V (-B, A);
42
43 //   gp_Pnt2d P;
44 //   Standard_Real Norm = sqrt(A * A + B * B);
45 //   Standard_ConstructionError_Raise_if (Norm <= gp::Resolution(), " ");
46 //   Standard_Real A1 = A/Norm;
47 //   Standard_Real B1 = B/Norm;
48 //   Standard_Real C1 = C/Norm;
49 //   gp_Dir2d V = gp_Dir2d (-B1, A1);
50 //   Standard_Real AA1 = A1;
51 //   if (AA1 < 0) AA1 = - AA1;
52 //   if (AA1 > gp::Resolution()) P.SetCoord (-C1 / A1, 0.0);
53 //   else                        P.SetCoord (0.0, -C1 / B1);
54
55   pos = gp_Ax2d(P, V);
56 }
57
58 //=======================================================================
59 //function : Mirror
60 //purpose  : 
61 //=======================================================================
62
63 void gp_Lin2d::Mirror (const gp_Pnt2d& P)
64 { pos.Mirror(P);  }
65
66 //=======================================================================
67 //function : Mirrored
68 //purpose  : 
69 //=======================================================================
70
71 gp_Lin2d gp_Lin2d::Mirrored (const gp_Pnt2d& P)  const
72 {
73   gp_Lin2d L = *this;    
74   L.pos.Mirror(P);
75   return L;
76 }
77
78 //=======================================================================
79 //function : Mirror
80 //purpose  : 
81 //=======================================================================
82
83 void gp_Lin2d::Mirror (const gp_Ax2d& A)
84 { pos.Mirror(A); }
85
86 //=======================================================================
87 //function : Mirrored
88 //purpose  : 
89 //=======================================================================
90
91 gp_Lin2d gp_Lin2d::Mirrored (const gp_Ax2d& A) const
92 {
93   gp_Lin2d L = *this;
94   L.pos.Mirror(A);
95   return L;
96 }
97