1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #define No_Standard_OutOfRange
22 #include <gp_GTrsf.ixx>
25 void gp_GTrsf::SetTranslationPart (const gp_XYZ& Coord)
28 if (Form() == gp_CompoundTrsf || Form() == gp_Other ||
29 Form() == gp_Translation) { }
30 else if (Form() == gp_Identity) { shape = gp_Translation; }
31 else { shape = gp_CompoundTrsf; }
34 void gp_GTrsf::Invert ()
36 if (shape == gp_Other) {
38 loc.Multiply (matrix);
48 void gp_GTrsf::Multiply (const gp_GTrsf& T)
50 if (Form() == gp_Other || T.Form() == gp_Other) {
52 loc.Add (T.loc.Multiplied (matrix));
53 matrix.Multiply(T.matrix);
57 gp_Trsf T2 = T.Trsf();
66 void gp_GTrsf::Power (const Standard_Integer N)
72 loc = gp_XYZ (0.,0.,0.);
75 else if (N == -1) { Invert(); }
77 if (shape == gp_Other) {
78 Standard_Integer Npower = N;
79 if (Npower < 0) Npower = - Npower;
82 // Standard_Real Tempscale = scale;
83 gp_Mat Tempmatrix (matrix);
86 loc.Add (Temploc.Multiplied (matrix));
87 matrix.Multiply (Tempmatrix);
89 if (Npower == 1) { break; }
90 Temploc.Add (Temploc.Multiplied (Tempmatrix));
91 Tempmatrix.Multiply (Tempmatrix);
103 void gp_GTrsf::PreMultiply (const gp_GTrsf& T)
105 if (Form() == gp_Other || T.Form() == gp_Other) {
107 loc.Multiply (T.matrix);
109 matrix.PreMultiply(T.matrix);
113 gp_Trsf T2 = T.Trsf();
122 void gp_GTrsf::SetForm()
124 Standard_Real tol = 1.e-12; // Precision::Angular();
126 // don t trust the initial values !
129 Standard_Real s = M.Determinant();
130 Standard_Real As = s;
131 if (As < 0) As = - As;
132 Standard_ConstructionError_Raise_if
133 (As < gp::Resolution(),"gp_GTrsf::SetForm, null determinant");
140 // check if the matrix is an uniform matrix
141 // the transposition should be the invert.
146 anIdentity.SetIdentity() ;
147 TM.Subtract(anIdentity);
148 if (shape==gp_Other) shape = gp_CompoundTrsf;
150 Standard_Integer i, j;
151 for (i=1; i<=3; i++) {
152 for (j=1; j<=3; j++) {
154 if (As < 0) As = - As;