@@ -27,76 +27,153 @@ public partial struct Matrix3
2727 /// <summary>
2828 /// Value at column 0, row 0 of the matrix.
2929 /// </summary>
30- public double m00 ;
30+ public double M00 ;
3131 /// <summary>
3232 /// Value at column 0, row 1 of the matrix.
3333 /// </summary>
34- public double m01 ;
34+ public double M01 ;
3535 /// <summary>
3636 /// Value at column 0, row 2 of the matrix.
3737 /// </summary>
38- public double m02 ;
38+ public double M02 ;
3939
4040 /// <summary>
4141 /// Value at column 1, row 0 of the matrix.
4242 /// </summary>
43- public double m10 ;
43+ public double M10 ;
4444 /// <summary>
4545 /// Value at column 1, row 1 of the matrix.
4646 /// </summary>
47- public double m11 ;
47+ public double M11 ;
4848 /// <summary>
4949 /// Value at column 1, row 2 of the matrix.
5050 /// </summary>
51- public double m12 ;
51+ public double M12 ;
5252
5353 /// <summary>
5454 /// Value at column 2, row 0 of the matrix.
5555 /// </summary>
56- public double m20 ;
56+ public double M20 ;
5757 /// <summary>
5858 /// Value at column 2, row 1 of the matrix.
5959 /// </summary>
60- public double m21 ;
60+ public double M21 ;
6161 /// <summary>
6262 /// Value at column 2, row 2 of the matrix.
6363 /// </summary>
64- public double m22 ;
64+ public double M22 ;
6565
6666 #endregion Public Fields
6767
68+ public double this [ int index ]
69+ {
70+ get
71+ {
72+ switch ( index )
73+ {
74+ case 0 :
75+ return this . M00 ;
76+ case 1 :
77+ return this . M01 ;
78+ case 2 :
79+ return this . M02 ;
80+ case 3 :
81+ return this . M10 ;
82+ case 4 :
83+ return this . M11 ;
84+ case 5 :
85+ return this . M12 ;
86+ case 6 :
87+ return this . M20 ;
88+ case 7 :
89+ return this . M21 ;
90+ case 8 :
91+ return this . M22 ;
92+ default :
93+ throw new IndexOutOfRangeException ( ) ;
94+ }
95+ }
96+ set
97+ {
98+ switch ( index )
99+ {
100+ case 0 :
101+ this . M00 = value ;
102+ break ;
103+ case 1 :
104+ this . M01 = value ;
105+ break ;
106+ case 2 :
107+ this . M02 = value ;
108+ break ;
109+ case 3 :
110+ this . M10 = value ;
111+ break ;
112+ case 4 :
113+ this . M11 = value ;
114+ break ;
115+ case 5 :
116+ this . M12 = value ;
117+ break ;
118+ case 6 :
119+ this . M20 = value ;
120+ break ;
121+ case 7 :
122+ this . M21 = value ;
123+ break ;
124+ case 8 :
125+ this . M22 = value ;
126+ break ;
127+ default :
128+ throw new IndexOutOfRangeException ( ) ;
129+ }
130+ }
131+ }
132+
133+ public double this [ int column , int row ]
134+ {
135+ get
136+ {
137+ return this [ ( column * 3 ) + row ] ;
138+ }
139+ set
140+ {
141+ this [ ( column * 3 ) + row ] = value ;
142+ }
143+ }
144+
68145 public Matrix3 (
69146 double m00 , double m10 , double m20 ,
70147 double m01 , double m11 , double m21 ,
71148 double m02 , double m12 , double m22 )
72149 {
73150 //Col 0
74- this . m00 = m00 ;
75- this . m01 = m01 ;
76- this . m02 = m02 ;
151+ this . M00 = m00 ;
152+ this . M01 = m01 ;
153+ this . M02 = m02 ;
77154
78155 //Col 1
79- this . m10 = m10 ;
80- this . m11 = m11 ;
81- this . m12 = m12 ;
156+ this . M10 = m10 ;
157+ this . M11 = m11 ;
158+ this . M12 = m12 ;
82159
83160 //Col 2
84- this . m20 = m20 ;
85- this . m21 = m21 ;
86- this . m22 = m22 ;
161+ this . M20 = m20 ;
162+ this . M21 = m21 ;
163+ this . M22 = m22 ;
87164 }
88165
89166 public Matrix3 ( Matrix4 matrix )
90167 {
91- this . m00 = matrix . m00 ;
92- this . m01 = matrix . m01 ;
93- this . m02 = matrix . m02 ;
94- this . m10 = matrix . m10 ;
95- this . m11 = matrix . m11 ;
96- this . m12 = matrix . m12 ;
97- this . m20 = matrix . m20 ;
98- this . m21 = matrix . m21 ;
99- this . m22 = matrix . m22 ;
168+ this . M00 = matrix . M00 ;
169+ this . M01 = matrix . M01 ;
170+ this . M02 = matrix . M02 ;
171+ this . M10 = matrix . M10 ;
172+ this . M11 = matrix . M11 ;
173+ this . M12 = matrix . M12 ;
174+ this . M20 = matrix . M20 ;
175+ this . M21 = matrix . M21 ;
176+ this . M22 = matrix . M22 ;
100177 }
101178
102179 /// <summary>
@@ -105,9 +182,9 @@ public Matrix3(Matrix4 matrix)
105182 /// <returns>Transpose matrix.</returns>
106183 public Matrix3 Transpose ( )
107184 {
108- return new Matrix3 ( this . m00 , this . m10 , this . m20 ,
109- this . m01 , this . m11 , this . m21 ,
110- this . m02 , this . m12 , this . m22 ) ;
185+ return new Matrix3 ( this . M00 , this . M10 , this . M20 ,
186+ this . M01 , this . M11 , this . M21 ,
187+ this . M02 , this . M12 , this . M22 ) ;
111188 }
112189
113190 /// <summary>
@@ -165,10 +242,10 @@ public override string ToString()
165242 {
166243 string separator = Thread . CurrentThread . CurrentCulture . TextInfo . ListSeparator ;
167244 StringBuilder s = new StringBuilder ( ) ;
168- s . Append ( string . Format ( "|{0}{2} {0}{2} {1}|" + Environment . NewLine , this . m00 , this . m01 , this . m02 , separator ) ) ;
169- s . Append ( string . Format ( "|{0}{2} {0}{2} {1}|" + Environment . NewLine , this . m10 , this . m11 , this . m12 , separator ) ) ;
170- s . Append ( string . Format ( "|{0}{2} {0}{2} {1}|" , this . m20 , this . m21 , this . m22 , separator ) ) ;
245+ s . Append ( string . Format ( "|{0}{2} {0}{2} {1}|" + Environment . NewLine , this . M00 , this . M01 , this . M02 , separator ) ) ;
246+ s . Append ( string . Format ( "|{0}{2} {0}{2} {1}|" + Environment . NewLine , this . M10 , this . M11 , this . M12 , separator ) ) ;
247+ s . Append ( string . Format ( "|{0}{2} {0}{2} {1}|" , this . M20 , this . M21 , this . M22 , separator ) ) ;
171248 return s . ToString ( ) ;
172249 }
173250 }
174- }
251+ }
0 commit comments