1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // JCV 1/10/90 Changement de nom du package vgeom -> gp
16 // JCV 12/12/90 Modif mineur suite a la premiere revue de projet
17 // LPA, JCV 07/92 passage sur C1.
18 // JCV 07/92 Introduction de la method Dump
20 #define No_Standard_OutOfRange
28 #include <gp_Trsf.hxx>
30 #include <Standard_ConstructionError.hxx>
31 #include <Standard_Dump.hxx>
33 gp_Ax2::gp_Ax2 (const gp_Pnt& P, const gp_Dir& V) :
36 Standard_Real A = V.X();
37 Standard_Real B = V.Y();
38 Standard_Real C = V.Z();
39 Standard_Real Aabs = A;
40 if (Aabs < 0) Aabs = - Aabs;
41 Standard_Real Babs = B;
42 if (Babs < 0) Babs = - Babs;
43 Standard_Real Cabs = C;
44 if (Cabs < 0) Cabs = - Cabs;
47 // pour determiner l axe X :
48 // on dit que le produit scalaire Vx.V = 0.
49 // et on recherche le max(A,B,C) pour faire la division.
50 // l'une des coordonnees du vecteur est nulle.
52 if ( Babs <= Aabs && Babs <= Cabs) {
53 if (Aabs > Cabs) D.SetCoord(-C,0., A);
54 else D.SetCoord( C,0.,-A);
56 else if ( Aabs <= Babs && Aabs <= Cabs) {
57 if (Babs > Cabs) D.SetCoord(0.,-C, B);
58 else D.SetCoord(0., C,-B);
61 if (Aabs > Babs) D.SetCoord(-B, A,0.);
62 else D.SetCoord( B,-A,0.);
67 void gp_Ax2::Mirror (const gp_Pnt& P)
69 gp_Pnt Temp = axis.Location();
71 axis.SetLocation (Temp);
76 gp_Ax2 gp_Ax2::Mirrored(const gp_Pnt& P) const
83 void gp_Ax2::Mirror (const gp_Ax1& A1)
87 gp_Pnt Temp = axis.Location();
89 axis.SetLocation (Temp);
90 axis.SetDirection (vxdir.Crossed (vydir));
93 gp_Ax2 gp_Ax2::Mirrored(const gp_Ax1& A1) const
100 void gp_Ax2::Mirror (const gp_Ax2& A2)
104 gp_Pnt Temp = axis.Location();
106 axis.SetLocation (Temp);
107 axis.SetDirection (vxdir.Crossed (vydir));
110 gp_Ax2 gp_Ax2::Mirrored(const gp_Ax2& A2) const
117 void gp_Ax2::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
119 OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, axis.Location().X(), axis.Location().Y(), axis.Location().Z())
120 OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, axis.Direction().X(), axis.Direction().Y(), axis.Direction().Z())
122 OCCT_DUMP_VECTOR_CLASS (theOStream, "XDirection", 3, vxdir.X(), vxdir.Y(), vxdir.Z())
123 OCCT_DUMP_VECTOR_CLASS (theOStream, "YDirection", 3, vydir.X(), vydir.Y(), vydir.Z())