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