400a00c57e9dc8ce6f1f3341eae91337ff54d929
[occt.git] / src / gp / gp_Hypr2d.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 #define No_Standard_OutOfRange
16
17
18 #include <gp_Ax2d.hxx>
19 #include <gp_Ax22d.hxx>
20 #include <gp_Hypr2d.hxx>
21 #include <gp_Pnt2d.hxx>
22 #include <gp_Trsf2d.hxx>
23 #include <gp_Vec2d.hxx>
24 #include <Standard_ConstructionError.hxx>
25 #include <Standard_DomainError.hxx>
26
27 void gp_Hypr2d::Coefficients (Standard_Real& A, 
28                               Standard_Real& B, 
29                               Standard_Real& C, 
30                               Standard_Real& D, 
31                               Standard_Real& E, 
32                               Standard_Real& F) const 
33 {
34   Standard_Real DMin = minorRadius * minorRadius;
35   Standard_Real DMaj = majorRadius * majorRadius;
36   if (DMin <= gp::Resolution() && DMaj <= gp::Resolution()) {
37     A = B = C = D = E = F = 0.0;
38   }
39   else {
40     gp_Trsf2d T;
41     T.SetTransformation (pos.XAxis());
42     Standard_Real T11 = T.Value (1, 1);
43     Standard_Real T12 = T.Value (1, 2);
44     Standard_Real T13 = T.Value (1, 3);
45     if (DMin <= gp::Resolution()) {
46       A = T11 * T11;   B = T12 * T12;   C = T11 * T12;
47       D = T11 * T13;   E = T12 * T13;   F = T13 * T13 - DMaj;
48     }
49     else {
50       Standard_Real T21 = T.Value (2, 1);
51       Standard_Real T22 = T.Value (2, 2);
52       Standard_Real T23 = T.Value (2, 3);
53       A = (T11 * T11 / DMaj) - (T21 * T21 / DMin);
54       B = (T12 * T12 / DMaj) - (T22 * T22 / DMin);
55       C = (T11 * T12 / DMaj) - (T21 * T22 / DMin);
56       D = (T11 * T13 / DMaj) - (T21 * T23 / DMin);
57       E = (T12 * T13 / DMaj) - (T22 * T23 / DMin);
58       F = (T13 * T13 / DMaj) - (T23 * T23 / DMin) - 1.0;
59     }
60   }
61 }
62
63 void gp_Hypr2d::Mirror (const gp_Pnt2d& P)
64 { pos.Mirror(P); }
65
66 gp_Hypr2d gp_Hypr2d::Mirrored (const gp_Pnt2d& P) const
67 {
68   gp_Hypr2d H = *this;
69   H.pos.Mirror (P);
70   return H; 
71 }
72
73 void gp_Hypr2d::Mirror (const gp_Ax2d& A)
74 { pos.Mirror(A); }
75
76 gp_Hypr2d gp_Hypr2d::Mirrored (const gp_Ax2d& A) const
77 {
78   gp_Hypr2d H = *this;
79   H.pos.Mirror (A);
80   return H; 
81 }
82