[OpenTK] Introduce OpenTK (#336)
[platform/core/csapi/tizenfx.git] / external / src / OpenTK / OpenTK / Math / Matrix2x3d.cs
1 /*
2 Copyright (c) 2006 - 2008 The Open Toolkit library.
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21  */
22
23 using System;
24
25 namespace OpenTK
26 {
27     /// <summary>
28     /// Represents a 2x3 matrix.
29     /// </summary>
30     public struct Matrix2x3d : IEquatable<Matrix2x3d>
31     {
32         /// <summary>
33         /// Top row of the matrix.
34         /// </summary>
35         public Vector3d Row0;
36
37         /// <summary>
38         /// Bottom row of the matrix.
39         /// </summary>
40         public Vector3d Row1;
41
42         /// <summary>
43         /// The zero matrix.
44         /// </summary>
45         public static readonly Matrix2x3d Zero = new Matrix2x3d(Vector3d.Zero, Vector3d.Zero);
46
47         /// <summary>
48         /// Constructs a new instance.
49         /// </summary>
50         /// <param name="row0">Top row of the matrix.</param>
51         /// <param name="row1">Bottom row of the matrix.</param>
52         public Matrix2x3d(Vector3d row0, Vector3d row1)
53         {
54             Row0 = row0;
55             Row1 = row1;
56         }
57
58         /// <summary>
59         /// Constructs a new instance
60         /// </summary>
61         /// <param name="m00">First item of the first row of the matrix.</param>
62         /// <param name="m01">Second item of the first row of the matrix.</param>
63         /// <param name="m02">Third item of the first row of the matrix.</param>
64         /// <param name="m10">First item of the second row of the matrix.</param>
65         /// <param name="m11">Second item of the second row of the matrix.</param>
66         /// <param name="m12">Third item of the second row of the matrix.</param>
67         public Matrix2x3d(
68             double m00, double m01, double m02,
69             double m10, double m11, double m12)
70         {
71             Row0 = new Vector3d(m00, m01, m02);
72             Row1 = new Vector3d(m10, m11, m12);
73         }
74
75         /// <summary>
76         /// Gets or sets the first column of this matrix.
77         /// </summary>
78         public Vector2d Column0
79         {
80             get { return new Vector2d(Row0.X, Row1.X); }
81             set { Row0.X = value.X; Row1.X = value.Y; }
82         }
83
84         /// <summary>
85         /// Gets or sets the second column of this matrix.
86         /// </summary>
87         public Vector2d Column1
88         {
89             get { return new Vector2d(Row0.Y, Row1.Y); }
90             set { Row0.Y = value.X; Row1.Y = value.Y; }
91         }
92
93         /// <summary>
94         /// Gets or sets the third column of this matrix.
95         /// </summary>
96         public Vector2d Column2
97         {
98             get { return new Vector2d(Row0.Z, Row1.Z); }
99             set { Row0.Z = value.X; Row1.Z = value.Y; }
100         }
101
102         /// <summary>
103         /// Gets or sets the value at row 1, column 1 of this instance.
104         /// </summary>
105         public double M11 { get { return Row0.X; } set { Row0.X = value; } }
106
107         /// <summary>
108         /// Gets or sets the value at row 1, column 2 of this instance.
109         /// </summary>
110         public double M12 { get { return Row0.Y; } set { Row0.Y = value; } }
111
112         /// <summary>
113         /// Gets or sets the value at row 1, column 3 of this instance.
114         /// </summary>
115         public double M13 { get { return Row0.Z; } set { Row0.Z = value; } }
116
117         /// <summary>
118         /// Gets or sets the value at row 2, column 1 of this instance.
119         /// </summary>
120         public double M21 { get { return Row1.X; } set { Row1.X = value; } }
121
122         /// <summary>
123         /// Gets or sets the value at row 2, column 2 of this instance.
124         /// </summary>
125         public double M22 { get { return Row1.Y; } set { Row1.Y = value; } }
126
127         /// <summary>
128         /// Gets or sets the value at row 2, column 3 of this instance.
129         /// </summary>
130         public double M23 { get { return Row1.Z; } set { Row1.Z = value; } }
131
132         /// <summary>
133         /// Gets or sets the values along the main diagonal of the matrix.
134         /// </summary>
135         public Vector2d Diagonal
136         {
137             get
138             {
139                 return new Vector2d(Row0.X, Row1.Y);
140             }
141             set
142             {
143                 Row0.X = value.X;
144                 Row1.Y = value.Y;
145             }
146         }
147
148         /// <summary>
149         /// Gets the trace of the matrix, the sum of the values along the diagonal.
150         /// </summary>
151         public double Trace { get { return Row0.X + Row1.Y; } }
152
153         /// <summary>
154         /// Gets or sets the value at a specified row and column.
155         /// </summary>
156         public double this[int rowIndex, int columnIndex]
157         {
158             get
159             {
160                 if (rowIndex == 0)
161                 {
162                     return Row0[columnIndex];
163                 }
164                 else if (rowIndex == 1)
165                 {
166                     return Row1[columnIndex];
167                 }
168                 throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
169             }
170             set
171             {
172                 if (rowIndex == 0)
173                 {
174                     Row0[columnIndex] = value;
175                 }
176                 else if (rowIndex == 1)
177                 {
178                     Row1[columnIndex] = value;
179                 }
180                 else
181                 {
182                     throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
183                 }
184             }
185         }
186
187         /// <summary>
188         /// Builds a rotation matrix.
189         /// </summary>
190         /// <param name="angle">The counter-clockwise angle in radians.</param>
191         /// <param name="result">The resulting Matrix2x3d instance.</param>
192         public static void CreateRotation(double angle, out Matrix2x3d result)
193         {
194             double cos = System.Math.Cos(angle);
195             double sin = System.Math.Sin(angle);
196
197             result.Row0.X = cos;
198             result.Row0.Y = sin;
199             result.Row0.Z = 0;
200             result.Row1.X = -sin;
201             result.Row1.Y = cos;
202             result.Row1.Z = 0;
203         }
204
205         /// <summary>
206         /// Builds a rotation matrix.
207         /// </summary>
208         /// <param name="angle">The counter-clockwise angle in radians.</param>
209         /// <returns>The resulting Matrix2x3d instance.</returns>
210         public static Matrix2x3d CreateRotation(double angle)
211         {
212             Matrix2x3d result;
213             CreateRotation(angle, out result);
214             return result;
215         }
216
217         /// <summary>
218         /// Creates a scale matrix.
219         /// </summary>
220         /// <param name="scale">Single scale factor for the x, y, and z axes.</param>
221         /// <param name="result">A scale matrix.</param>
222         public static void CreateScale(double scale, out Matrix2x3d result)
223         {
224             result.Row0.X = scale;
225             result.Row0.Y = 0;
226             result.Row0.Z = 0;
227             result.Row1.X = 0;
228             result.Row1.Y = scale;
229             result.Row1.Z = 0;
230         }
231
232         /// <summary>
233         /// Creates a scale matrix.
234         /// </summary>
235         /// <param name="scale">Single scale factor for the x and y axes.</param>
236         /// <returns>A scale matrix.</returns>
237         public static Matrix2x3d CreateScale(double scale)
238         {
239             Matrix2x3d result;
240             CreateScale(scale, out result);
241             return result;
242         }
243
244         /// <summary>
245         /// Creates a scale matrix.
246         /// </summary>
247         /// <param name="scale">Scale factors for the x and y axes.</param>
248         /// <param name="result">A scale matrix.</param>
249         public static void CreateScale(Vector2d scale, out Matrix2x3d result)
250         {
251             result.Row0.X = scale.X;
252             result.Row0.Y = 0;
253             result.Row0.Z = 0;
254             result.Row1.X = 0;
255             result.Row1.Y = scale.Y;
256             result.Row1.Z = 0;
257         }
258
259         /// <summary>
260         /// Creates a scale matrix.
261         /// </summary>
262         /// <param name="scale">Scale factors for the x and y axes.</param>
263         /// <returns>A scale matrix.</returns>
264         public static Matrix2x3d CreateScale(Vector2d scale)
265         {
266             Matrix2x3d result;
267             CreateScale(scale, out result);
268             return result;
269         }
270
271         /// <summary>
272         /// Creates a scale matrix.
273         /// </summary>
274         /// <param name="x">Scale factor for the x axis.</param>
275         /// <param name="y">Scale factor for the y axis.</param>
276         /// <param name="result">A scale matrix.</param>
277         public static void CreateScale(double x, double y, out Matrix2x3d result)
278         {
279             result.Row0.X = x;
280             result.Row0.Y = 0;
281             result.Row0.Z = 0;
282             result.Row1.X = 0;
283             result.Row1.Y = y;
284             result.Row1.Z = 0;
285         }
286
287         /// <summary>
288         /// Creates a scale matrix.
289         /// </summary>
290         /// <param name="x">Scale factor for the x axis.</param>
291         /// <param name="y">Scale factor for the y axis.</param>
292         /// <returns>A scale matrix.</returns>
293         public static Matrix2x3d CreateScale(double x, double y)
294         {
295             Matrix2x3d result;
296             CreateScale(x, y, out result);
297             return result;
298         }
299
300         /// <summary>
301         /// Multiplies and instance by a scalar.
302         /// </summary>
303         /// <param name="left">The left operand of the multiplication.</param>
304         /// <param name="right">The right operand of the multiplication.</param>
305         /// <param name="result">A new instance that is the result of the multiplication.</param>
306         public static void Mult(ref Matrix2x3d left, double right, out Matrix2x3d result)
307         {
308             result.Row0.X = left.Row0.X * right;
309             result.Row0.Y = left.Row0.Y * right;
310             result.Row0.Z = left.Row0.Z * right;
311             result.Row1.X = left.Row1.X * right;
312             result.Row1.Y = left.Row1.Y * right;
313             result.Row1.Z = left.Row1.Z * right;
314         }
315
316         /// <summary>
317         /// Multiplies and instance by a scalar.
318         /// </summary>
319         /// <param name="left">The left operand of the multiplication.</param>
320         /// <param name="right">The right operand of the multiplication.</param>
321         /// <returns>A new instance that is the result of the multiplication.</returns>
322         public static Matrix2x3d Mult(Matrix2x3d left, double right)
323         {
324             Matrix2x3d result;
325             Mult(ref left, right, out result);
326             return result;
327         }
328
329         /// <summary>
330         /// Multiplies two instances.
331         /// </summary>
332         /// <param name="left">The left operand of the multiplication.</param>
333         /// <param name="right">The right operand of the multiplication.</param>
334         /// <param name="result">A new instance that is the result of the multiplication.</param>
335         public static void Mult(ref Matrix2x3d left, ref Matrix3x2 right, out Matrix2d result)
336         {
337             double lM11 = left.Row0.X, lM12 = left.Row0.Y, lM13 = left.Row0.Z,
338                 lM21 = left.Row1.X, lM22 = left.Row1.Y, lM23 = left.Row1.Z,
339                 rM11 = right.Row0.X, rM12 = right.Row0.Y,
340                 rM21 = right.Row1.X, rM22 = right.Row1.Y,
341                 rM31 = right.Row2.X, rM32 = right.Row2.Y;
342
343             result.Row0.X = ((lM11 * rM11) + (lM12 * rM21)) + (lM13 * rM31);
344             result.Row0.Y = ((lM11 * rM12) + (lM12 * rM22)) + (lM13 * rM32);
345             result.Row1.X = ((lM21 * rM11) + (lM22 * rM21)) + (lM23 * rM31);
346             result.Row1.Y = ((lM21 * rM12) + (lM22 * rM22)) + (lM23 * rM32);
347         }
348
349         /// <summary>
350         /// Multiplies two instances.
351         /// </summary>
352         /// <param name="left">The left operand of the multiplication.</param>
353         /// <param name="right">The right operand of the multiplication.</param>
354         /// <returns>A new instance that is the result of the multiplication.</returns>
355         public static Matrix2d Mult(Matrix2x3d left, Matrix3x2 right)
356         {
357             Matrix2d result;
358             Mult(ref left, ref right, out result);
359             return result;
360         }
361
362         /// <summary>
363         /// Multiplies two instances.
364         /// </summary>
365         /// <param name="left">The left operand of the multiplication.</param>
366         /// <param name="right">The right operand of the multiplication.</param>
367         /// <param name="result">A new instance that is the result of the multiplication.</param>
368         public static void Mult(ref Matrix2x3d left, ref Matrix3 right, out Matrix2x3d result)
369         {
370             double lM11 = left.Row0.X, lM12 = left.Row0.Y, lM13 = left.Row0.Z,
371                 lM21 = left.Row1.X, lM22 = left.Row1.Y, lM23 = left.Row1.Z,
372                 rM11 = right.Row0.X, rM12 = right.Row0.Y, rM13 = right.Row0.Z,
373                 rM21 = right.Row1.X, rM22 = right.Row1.Y, rM23 = right.Row1.Z,
374                 rM31 = right.Row2.X, rm32 = right.Row2.Y, rM33 = right.Row2.Z;
375
376             result.Row0.X = ((lM11 * rM11) + (lM12 * rM21)) + (lM13 * rM31);
377             result.Row0.Y = ((lM11 * rM12) + (lM12 * rM22)) + (lM13 * rm32);
378             result.Row0.Z = ((lM11 * rM13) + (lM12 * rM23)) + (lM13 * rM33);
379             result.Row1.X = ((lM21 * rM11) + (lM22 * rM21)) + (lM23 * rM31);
380             result.Row1.Y = ((lM21 * rM12) + (lM22 * rM22)) + (lM23 * rm32);
381             result.Row1.Z = ((lM21 * rM13) + (lM22 * rM23)) + (lM23 * rM33);
382         }
383
384         /// <summary>
385         /// Multiplies two instances.
386         /// </summary>
387         /// <param name="left">The left operand of the multiplication.</param>
388         /// <param name="right">The right operand of the multiplication.</param>
389         /// <returns>A new instance that is the result of the multiplication.</returns>
390         public static Matrix2x3d Mult(Matrix2x3d left, Matrix3 right)
391         {
392             Matrix2x3d result;
393             Mult(ref left, ref right, out result);
394             return result;
395         }
396
397         /// <summary>
398         /// Multiplies two instances.
399         /// </summary>
400         /// <param name="left">The left operand of the multiplication.</param>
401         /// <param name="right">The right operand of the multiplication.</param>
402         /// <param name="result">A new instance that is the result of the multiplication.</param>
403         public static void Mult(ref Matrix2x3d left, ref Matrix3x4 right, out Matrix2x4d result)
404         {
405             double lM11 = left.Row0.X, lM12 = left.Row0.Y, lM13 = left.Row0.Z,
406                 lM21 = left.Row1.X, lM22 = left.Row1.Y, lM23 = left.Row1.Z,
407                 rM11 = right.Row0.X, rM12 = right.Row0.Y, rM13 = right.Row0.Z, rM14 = right.Row0.W,
408                 rM21 = right.Row1.X, rM22 = right.Row1.Y, rM23 = right.Row1.Z, rM24 = right.Row1.W,
409                 rM31 = right.Row2.X, rm32 = right.Row2.Y, rM33 = right.Row2.Z, rM34 = right.Row2.W;
410
411             result.Row0.X = ((lM11 * rM11) + (lM12 * rM21)) + (lM13 * rM31);
412             result.Row0.Y = ((lM11 * rM12) + (lM12 * rM22)) + (lM13 * rm32);
413             result.Row0.Z = ((lM11 * rM13) + (lM12 * rM23)) + (lM13 * rM33);
414             result.Row0.W = ((lM11 * rM14) + (lM12 * rM24)) + (lM13 * rM34);
415             result.Row1.X = ((lM21 * rM11) + (lM22 * rM21)) + (lM23 * rM31);
416             result.Row1.Y = ((lM21 * rM12) + (lM22 * rM22)) + (lM23 * rm32);
417             result.Row1.Z = ((lM21 * rM13) + (lM22 * rM23)) + (lM23 * rM33);
418             result.Row1.W = ((lM21 * rM14) + (lM22 * rM24)) + (lM23 * rM34);
419         }
420
421         /// <summary>
422         /// Multiplies two instances.
423         /// </summary>
424         /// <param name="left">The left operand of the multiplication.</param>
425         /// <param name="right">The right operand of the multiplication.</param>
426         /// <returns>A new instance that is the result of the multiplication.</returns>
427         public static Matrix2x4d Mult(Matrix2x3d left, Matrix3x4 right)
428         {
429             Matrix2x4d result;
430             Mult(ref left, ref right, out result);
431             return result;
432         }
433
434         /// <summary>
435         /// Adds two instances.
436         /// </summary>
437         /// <param name="left">The left operand of the addition.</param>
438         /// <param name="right">The right operand of the addition.</param>
439         /// <param name="result">A new instance that is the result of the addition.</param>
440         public static void Add(ref Matrix2x3d left, ref Matrix2x3d right, out Matrix2x3d result)
441         {
442             result.Row0.X = left.Row0.X + right.Row0.X;
443             result.Row0.Y = left.Row0.Y + right.Row0.Y;
444             result.Row0.Z = left.Row0.Z + right.Row0.Z;
445             result.Row1.X = left.Row1.X + right.Row1.X;
446             result.Row1.Y = left.Row1.Y + right.Row1.Y;
447             result.Row1.Z = left.Row1.Z + right.Row1.Z;
448         }
449
450         /// <summary>
451         /// Adds two instances.
452         /// </summary>
453         /// <param name="left">The left operand of the addition.</param>
454         /// <param name="right">The right operand of the addition.</param>
455         /// <returns>A new instance that is the result of the addition.</returns>
456         public static Matrix2x3d Add(Matrix2x3d left, Matrix2x3d right)
457         {
458             Matrix2x3d result;
459             Add(ref left, ref right, out result);
460             return result;
461         }
462
463         /// <summary>
464         /// Subtracts two instances.
465         /// </summary>
466         /// <param name="left">The left operand of the subtraction.</param>
467         /// <param name="right">The right operand of the subtraction.</param>
468         /// <param name="result">A new instance that is the result of the subtraction.</param>
469         public static void Subtract(ref Matrix2x3d left, ref Matrix2x3d right, out Matrix2x3d result)
470         {
471             result.Row0.X = left.Row0.X - right.Row0.X;
472             result.Row0.Y = left.Row0.Y - right.Row0.Y;
473             result.Row0.Z = left.Row0.Z - right.Row0.Z;
474             result.Row1.X = left.Row1.X - right.Row1.X;
475             result.Row1.Y = left.Row1.Y - right.Row1.Y;
476             result.Row1.Z = left.Row1.Z - right.Row1.Z;
477         }
478
479         /// <summary>
480         /// Subtracts two instances.
481         /// </summary>
482         /// <param name="left">The left operand of the subtraction.</param>
483         /// <param name="right">The right operand of the subtraction.</param>
484         /// <returns>A new instance that is the result of the subtraction.</returns>
485         public static Matrix2x3d Subtract(Matrix2x3d left, Matrix2x3d right)
486         {
487             Matrix2x3d result;
488             Subtract(ref left, ref right, out result);
489             return result;
490         }
491
492         /// <summary>
493         /// Calculate the transpose of the given matrix.
494         /// </summary>
495         /// <param name="mat">The matrix to transpose.</param>
496         /// <param name="result">The transpose of the given matrix.</param>
497         public static void Transpose(ref Matrix2x3d mat, out Matrix3x2d result)
498         {
499             result.Row0.X = mat.Row0.X;
500             result.Row0.Y = mat.Row1.X;
501             result.Row1.X = mat.Row0.Y;
502             result.Row1.Y = mat.Row1.Y;
503             result.Row2.X = mat.Row0.Z;
504             result.Row2.Y = mat.Row1.Z;
505         }
506
507         /// <summary>
508         /// Calculate the transpose of the given matrix.
509         /// </summary>
510         /// <param name="mat">The matrix to transpose.</param>
511         /// <returns>The transpose of the given matrix.</returns>
512         public static Matrix3x2d Transpose(Matrix2x3d mat)
513         {
514             Matrix3x2d result;
515             Transpose(ref mat, out result);
516             return result;
517         }
518
519         /// <summary>
520         /// Scalar multiplication.
521         /// </summary>
522         /// <param name="left">left-hand operand</param>
523         /// <param name="right">right-hand operand</param>
524         /// <returns>A new Matrix2x3d which holds the result of the multiplication</returns>
525         public static Matrix2x3d operator *(double left, Matrix2x3d right)
526         {
527             return Mult(right, left);
528         }
529
530         /// <summary>
531         /// Scalar multiplication.
532         /// </summary>
533         /// <param name="left">left-hand operand</param>
534         /// <param name="right">right-hand operand</param>
535         /// <returns>A new Matrix2x3d which holds the result of the multiplication</returns>
536         public static Matrix2x3d operator *(Matrix2x3d left, double right)
537         {
538             return Mult(left, right);
539         }
540
541         /// <summary>
542         /// Matrix multiplication
543         /// </summary>
544         /// <param name="left">left-hand operand</param>
545         /// <param name="right">right-hand operand</param>
546         /// <returns>A new Matrix2d which holds the result of the multiplication</returns>
547         public static Matrix2d operator *(Matrix2x3d left, Matrix3x2 right)
548         {
549             return Mult(left, right);
550         }
551
552         /// <summary>
553         /// Matrix multiplication
554         /// </summary>
555         /// <param name="left">left-hand operand</param>
556         /// <param name="right">right-hand operand</param>
557         /// <returns>A new Matrix2x3d which holds the result of the multiplication</returns>
558         public static Matrix2x3d operator *(Matrix2x3d left, Matrix3 right)
559         {
560             return Mult(left, right);
561         }
562
563         /// <summary>
564         /// Matrix multiplication
565         /// </summary>
566         /// <param name="left">left-hand operand</param>
567         /// <param name="right">right-hand operand</param>
568         /// <returns>A new Matrix2x4d which holds the result of the multiplication</returns>
569         public static Matrix2x4d operator *(Matrix2x3d left, Matrix3x4 right)
570         {
571             return Mult(left, right);
572         }
573
574         /// <summary>
575         /// Matrix addition
576         /// </summary>
577         /// <param name="left">left-hand operand</param>
578         /// <param name="right">right-hand operand</param>
579         /// <returns>A new Matrix2x3d which holds the result of the addition</returns>
580         public static Matrix2x3d operator +(Matrix2x3d left, Matrix2x3d right)
581         {
582             return Add(left, right);
583         }
584
585         /// <summary>
586         /// Matrix subtraction
587         /// </summary>
588         /// <param name="left">left-hand operand</param>
589         /// <param name="right">right-hand operand</param>
590         /// <returns>A new Matrix2x3d which holds the result of the subtraction</returns>
591         public static Matrix2x3d operator -(Matrix2x3d left, Matrix2x3d right)
592         {
593             return Subtract(left, right);
594         }
595
596         /// <summary>
597         /// Compares two instances for equality.
598         /// </summary>
599         /// <param name="left">The first instance.</param>
600         /// <param name="right">The second instance.</param>
601         /// <returns>True, if left equals right; false otherwise.</returns>
602         public static bool operator ==(Matrix2x3d left, Matrix2x3d right)
603         {
604             return left.Equals(right);
605         }
606
607         /// <summary>
608         /// Compares two instances for inequality.
609         /// </summary>
610         /// <param name="left">The first instance.</param>
611         /// <param name="right">The second instance.</param>
612         /// <returns>True, if left does not equal right; false otherwise.</returns>
613         public static bool operator !=(Matrix2x3d left, Matrix2x3d right)
614         {
615             return !left.Equals(right);
616         }
617
618         /// <summary>
619         /// Returns a System.String that represents the current Matrix2x3d.
620         /// </summary>
621         /// <returns>The string representation of the matrix.</returns>
622         public override string ToString()
623         {
624             return String.Format("{0}\n{1}", Row0, Row1);
625         }
626
627         /// <summary>
628         /// Returns the hashcode for this instance.
629         /// </summary>
630         /// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
631         public override int GetHashCode()
632         {
633             unchecked
634             {
635                 return (this.Row0.GetHashCode() * 397) ^ this.Row1.GetHashCode();
636             }
637         }
638
639         /// <summary>
640         /// Indicates whether this instance and a specified object are equal.
641         /// </summary>
642         /// <param name="obj">The object to compare tresult.</param>
643         /// <returns>True if the instances are equal; false otherwise.</returns>
644         public override bool Equals(object obj)
645         {
646             if (!(obj is Matrix2x3d))
647             {
648                 return false;
649             }
650
651             return this.Equals((Matrix2x3d)obj);
652         }
653
654         /// <summary>
655         /// Indicates whether the current matrix is equal to another matrix.
656         /// </summary>
657         /// <param name="other">An matrix to compare with this matrix.</param>
658         /// <returns>true if the current matrix is equal to the matrix parameter; otherwise, false.</returns>
659         public bool Equals(Matrix2x3d other)
660         {
661             return
662                 Row0 == other.Row0 &&
663                 Row1 == other.Row1;
664         }
665     }
666 }