1 -- Copyright (c) 1991-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 class Mat2d from gp inherits Storable
22 -- Describes a two column, two row matrix. This sort of
23 -- object is used in various vectorial or matrix computations.
28 raises ConstructionError from Standard,
29 OutOfRange from Standard
39 --- Purpose : Creates a matrix with null coefficients.
42 Create (Col1, Col2 : XY) returns Mat2d;
44 -- Col1, Col2 are the 2 columns of the matrix.
50 SetCol (me : in out; Col : Integer; Value : XY)
51 --- Purpose : Assigns the two coordinates of Value to the column of range
53 -- Raises OutOfRange if Col < 1 or Col > 2.
58 SetCols (me : in out; Col1, Col2 : XY)
59 --- Purpose : Assigns the number pairs Col1, Col2 to the two columns of this matrix
63 SetDiagonal (me : in out; X1, X2 : Real) is static;
66 -- Modifies the main diagonal of the matrix.
67 -- <me>.Value (1, 1) = X1
68 -- <me>.Value (2, 2) = X2
69 -- The other coefficients of the matrix are not modified.
72 SetIdentity (me : in out) is static;
74 --- Purpose : Modifies this matrix, so that it represents the Identity matrix.
77 SetRotation (me : in out; Ang : Real) is static;
79 -- Modifies this matrix, so that it representso a rotation. Ang is the angular
80 -- value in radian of the rotation.
83 SetRow (me : in out; Row : Integer; Value : XY)
84 --- Purpose : Assigns the two coordinates of Value to the row of index Row of this matrix.
85 -- Raises OutOfRange if Row < 1 or Row > 2.
90 SetRows (me : in out; Row1, Row2 : XY) is static;
91 --- Purpose : Assigns the number pairs Row1, Row2 to the two rows of this matrix.
94 SetScale (me : in out; S : Real) is static;
97 -- Modifies the matrix such that it
98 -- represents a scaling transformation, where S is the scale factor :
103 SetValue (me : in out; Row, Col : Integer; Value : Real)
104 --- Purpose : Assigns <Value> to the coefficient of row Row, column Col of this matrix.
105 -- Raises OutOfRange if Row < 1 or Row > 2 or Col < 1 or Col > 2
110 Column (me; Col : Integer) returns XY
111 --- Purpose : Returns the column of Col index.
112 -- Raises OutOfRange if Col < 1 or Col > 2
117 Determinant (me) returns Real is static;
119 --- Purpose : Computes the determinant of the matrix.
122 Diagonal (me) returns XY is static;
123 --- Purpose : Returns the main diagonal of the matrix.
126 Row (me; Row : Integer) returns XY
127 --- Purpose : Returns the row of index Row.
129 --- Purpose : Raised if Row < 1 or Row > 2
133 Value (me; Row, Col : Integer) returns Real
134 --- Purpose : Returns the coefficient of range (Row, Col)
136 -- if Row < 1 or Row > 2 or Col < 1 or Col > 2
138 ---C++: return const &
139 ---C++: alias operator()
145 ChangeValue (me : in out; Row, Col : Integer) returns Real
146 --- Purpose : Returns the coefficient of range (Row, Col)
148 -- if Row < 1 or Row > 2 or Col < 1 or Col > 2
151 ---C++: alias operator()
157 IsSingular (me) returns Boolean is static;
159 -- Returns true if this matrix is singular (and therefore, cannot be inverted).
160 -- The Gauss LU decomposition is used to invert the matrix
161 -- so the matrix is considered as singular if the largest
162 -- pivot found is lower or equal to Resolution from gp.
166 Add (me : in out; Other : Mat2d) is static;
168 ---C++: alias operator +=
170 Added (me; Other : Mat2d) returns Mat2d is static;
172 ---C++: alias operator +
175 -- Computes the sum of this matrix and the matrix
176 -- Other.for each coefficient of the matrix :
177 -- <me>.Coef(i,j) + <Other>.Coef(i,j)
179 -- - operator += assigns the result to this matrix, while
180 -- - operator + creates a new one.
184 Divide (me : in out; Scalar : Real) is static;
186 ---C++: alias operator /=
188 Divided (me; Scalar : Real) returns Mat2d is static;
190 ---C++: alias operator /
192 -- Divides all the coefficients of the matrix by a scalar.
196 Invert (me : in out) raises ConstructionError is static;
198 Inverted (me) returns Mat2d raises ConstructionError is static;
200 -- Inverses the matrix and raises exception if the matrix
206 Multiplied (me; Other : Mat2d) returns Mat2d is static;
208 ---C++: alias operator *
210 Multiply (me : in out; Other : Mat2d) is static;
212 -- Computes the product of two matrices <me> * <Other>
214 -- C++: alias operator *=
216 PreMultiply(me : in out; Other : Mat2d) is static;
217 --- Purpose : Modifies this matrix by premultiplying it by the matrix Other
218 -- <me> = Other * <me>.
223 Multiplied (me; Scalar : Real) returns Mat2d is static;
225 ---C++: alias operator *
227 Multiply (me : in out; Scalar : Real) is static;
229 -- Multiplies all the coefficients of the matrix by a scalar.
231 ---C++: alias operator *=
234 Power (me : in out; N : Integer) raises ConstructionError is static;
236 Powered (me; N : Integer) returns Mat2d raises ConstructionError is static;
238 -- computes <me> = <me> * <me> * .......* <me>, N time.
239 -- if N = 0 <me> = Identity
240 -- if N < 0 <me> = <me>.Invert() *...........* <me>.Invert().
241 -- If N < 0 an exception can be raised if the matrix is not
246 Subtract (me : in out; Other : Mat2d) is static;
248 ---C++: alias operator -=
250 Subtracted (me; Other : Mat2d) returns Mat2d is static;
252 ---C++: alias operator -
254 -- Computes for each coefficient of the matrix :
255 -- <me>.Coef(i,j) - <Other>.Coef(i,j)
258 Transpose (me : in out) is static;
261 Transposed (me) returns Mat2d is static;
263 -- Transposes the matrix. A(j, i) -> A (i, j)
271 class Trsf2d from gp,
272 class GTrsf2d from gp,