0026747: Some constructors of gp_Parab2d class contain redundant parameters
[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
c1609fbe 26gp_Parab2d::gp_Parab2d (const gp_Ax2d& theDirectrix,
27 const gp_Pnt2d& theFocus,
28 const Standard_Boolean theSense)
7fd59977 29{
c1609fbe 30 const gp_Pnt2d &aDirLoc = theDirectrix.Location();
31 const gp_Dir2d &aDirVec = theDirectrix.Direction();
7fd59977 32
c1609fbe 33 const gp_Vec2d aFVec(aDirLoc, theFocus);
34
35 const gp_Pnt2d anOrigin(aDirLoc.XY()+aDirVec.XY()*(aFVec.Dot(aDirVec)));
36 const gp_Pnt2d anApex(0.5*(anOrigin.XY()+theFocus.XY()));
37
38 focalLength = 0.5*anOrigin.Distance(theFocus);
39
40 gp_Dir2d aXDir = (focalLength > 0.0) ? gp_Dir2d(theFocus.XY()-anOrigin.XY()) :
41 theDirectrix.Rotated(aDirLoc,
42 theSense ? -M_PI_2 : M_PI_2).Direction();
43
44 pos = gp_Ax22d(anApex, aXDir, aDirVec);
7fd59977 45}
46
47void gp_Parab2d::Coefficients
48(Standard_Real& A, Standard_Real& B, Standard_Real& C,
49 Standard_Real& D, Standard_Real& E, Standard_Real& F) const
50{
51 Standard_Real P = 2.0 * focalLength;
52 gp_Trsf2d T;
53 T.SetTransformation (pos.XAxis());
54 Standard_Real T11 = T.Value (1, 1);
55 Standard_Real T12 = T.Value (1, 2);
56 Standard_Real T13 = T.Value (1, 3);
57 Standard_Real T21 = T.Value (2, 1);
58 Standard_Real T22 = T.Value (2, 2);
59 Standard_Real T23 = T.Value (2, 3);
60 A = T21 * T21;
61 B = T22 * T22;
62 C = T21 * T22;
63 D = (T21 * T23) - (P * T11);
64 E = (T22 * T23) - (P * T12);
65 F = (T23 * T23) - (2.0 * P * T13);
66}
67
68void gp_Parab2d::Mirror (const gp_Pnt2d& P)
69{ pos.Mirror (P); }
70
71gp_Parab2d gp_Parab2d::Mirrored (const gp_Pnt2d& P) const
72{
73 gp_Parab2d Prb = *this;
74 Prb.pos.Mirror (P);
75 return Prb;
76}
77
78void gp_Parab2d::Mirror (const gp_Ax2d& A)
79{ pos.Mirror (A); }
80
81gp_Parab2d gp_Parab2d::Mirrored (const gp_Ax2d& A) const
82{
83 gp_Parab2d Prb = *this;
84 Prb.pos.Mirror (A);
85 return Prb;
86}
87