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 | #define No_Standard_OutOfRange |
16 | |
17 | #include <gp_Parab2d.ixx> |
18 | |
19 | gp_Parab2d::gp_Parab2d (const gp_Ax22d& D, |
20 | const gp_Pnt2d& F) |
21 | { |
22 | gp_XY DCoord = D.XDirection().XY(); |
23 | gp_XY GCoord = D.YDirection().XY(); |
24 | gp_XY PCoord = D.Location().XY(); |
25 | gp_XY MCoord = F.XY(); |
26 | focalLength = DCoord.Dot ( MCoord.Subtracted (PCoord)); |
27 | if (focalLength < 0) focalLength = - focalLength; |
28 | gp_XY N = GCoord; |
29 | N.Multiply (focalLength); |
30 | MCoord.Add (N); |
31 | N.Reverse(); |
32 | pos = gp_Ax22d (gp_Pnt2d (MCoord), gp_Dir2d (N)); |
33 | focalLength = focalLength / 2.0; |
34 | } |
35 | |
36 | gp_Parab2d::gp_Parab2d (const gp_Ax2d& D, |
37 | const gp_Pnt2d& F, |
38 | const Standard_Boolean Sense) |
39 | { |
40 | gp_XY DCoord = D.Direction().XY(); |
41 | gp_XY PCoord = D.Location().XY(); |
42 | gp_XY MCoord = F.XY(); |
43 | focalLength = DCoord.Dot ( MCoord.Subtracted (PCoord)); |
44 | if (focalLength < 0) focalLength = - focalLength; |
45 | gp_XY N; |
46 | if (Sense) N.SetCoord(DCoord.Y(), -DCoord.X()); |
47 | else N.SetCoord(-DCoord.Y(), DCoord.X()); |
48 | N.Multiply (focalLength); |
49 | MCoord.Add (N); |
50 | N.Reverse(); |
51 | pos = gp_Ax22d (gp_Pnt2d (MCoord), gp_Dir2d (N),Sense); |
52 | focalLength = focalLength / 2.0; |
53 | } |
54 | |
55 | void gp_Parab2d::Coefficients |
56 | (Standard_Real& A, Standard_Real& B, Standard_Real& C, |
57 | Standard_Real& D, Standard_Real& E, Standard_Real& F) const |
58 | { |
59 | Standard_Real P = 2.0 * focalLength; |
60 | gp_Trsf2d T; |
61 | T.SetTransformation (pos.XAxis()); |
62 | Standard_Real T11 = T.Value (1, 1); |
63 | Standard_Real T12 = T.Value (1, 2); |
64 | Standard_Real T13 = T.Value (1, 3); |
65 | Standard_Real T21 = T.Value (2, 1); |
66 | Standard_Real T22 = T.Value (2, 2); |
67 | Standard_Real T23 = T.Value (2, 3); |
68 | A = T21 * T21; |
69 | B = T22 * T22; |
70 | C = T21 * T22; |
71 | D = (T21 * T23) - (P * T11); |
72 | E = (T22 * T23) - (P * T12); |
73 | F = (T23 * T23) - (2.0 * P * T13); |
74 | } |
75 | |
76 | void gp_Parab2d::Mirror (const gp_Pnt2d& P) |
77 | { pos.Mirror (P); } |
78 | |
79 | gp_Parab2d gp_Parab2d::Mirrored (const gp_Pnt2d& P) const |
80 | { |
81 | gp_Parab2d Prb = *this; |
82 | Prb.pos.Mirror (P); |
83 | return Prb; |
84 | } |
85 | |
86 | void gp_Parab2d::Mirror (const gp_Ax2d& A) |
87 | { pos.Mirror (A); } |
88 | |
89 | gp_Parab2d gp_Parab2d::Mirrored (const gp_Ax2d& A) const |
90 | { |
91 | gp_Parab2d Prb = *this; |
92 | Prb.pos.Mirror (A); |
93 | return Prb; |
94 | } |
95 | |