2using System.Collections.Generic;
3using System.Globalization;
44 public Matrix3(
float d00,
float d01,
float d02,
45 float d10,
float d11,
float d12,
46 float d20,
float d21,
float d22)
59 public float this[
int row,
int column]
63 return this[row + column * 3];
67 this[row + column * 3] = value;
71 public float this[
int index]
96 throw new IndexOutOfRangeException(
"Invalid matrix index!");
131 throw new IndexOutOfRangeException(
"Invalid matrix index!");
136 public override bool Equals(
object other)
168 result.
x = lhs.
m00 * vector.
x + lhs.
m01 * vector.
y + lhs.
m02 * vector.
z;
169 result.
y = lhs.
m10 * vector.
x + lhs.
m11 * vector.
y + lhs.
m12 * vector.
z;
170 result.
z = lhs.
m20 * vector.
x + lhs.
m21 * vector.
y + lhs.
m22 * vector.
z;
181 return !(lhs == rhs);
199 throw new IndexOutOfRangeException(
"Invalid column index!");
218 throw new IndexOutOfRangeException(
"Invalid row index!");
229 this[0, index] = column.
x;
230 this[1, index] = column.
y;
231 this[2, index] = column.
z;
241 this[index, 0] = row.
x;
242 this[index, 1] = row.
y;
243 this[index, 2] = row.
z;
266 result.
m00 = vector.
x;
270 result.
m11 = vector.
y;
274 result.
m22 = vector.
z;
284 float num = q.
x * 2f;
285 float num2 = q.
y * 2f;
286 float num3 = q.
z * 2f;
287 float num4 = q.
x * num;
288 float num5 = q.
y * num2;
289 float num6 = q.
z * num3;
290 float num7 = q.
x * num2;
291 float num8 = q.
x * num3;
292 float num9 = q.
y * num3;
293 float num10 = q.
w * num;
294 float num11 = q.
w * num2;
295 float num12 = q.
w * num3;
297 result.
m00 = 1f - (num5 + num6);
298 result.
m10 = num7 + num12;
299 result.
m20 = num8 - num11;
300 result.
m01 = num7 - num12;
301 result.
m11 = 1f - (num4 + num6);
302 result.
m21 = num9 + num10;
303 result.
m02 = num8 + num11;
304 result.
m12 = num9 - num10;
305 result.
m22 = 1f - (num4 + num5);
315 return String.Format(
"{0:F5}\t{1:F5}\t{2:F5}\t{3:F5}\n{4:F5}\t{5:F5}\t{6:F5}\t{7:F5}\n{8:F5}\n",
m00,
m01,
m02,
m10,
m11,
m12,
m20,
m21,
m22);
324 return String.Format(
"{0}\t{1}\t{2}\t{3}\n{4}\t{5}\t{6}\t{7}\n{8}\n", ToInvariantString(format,
m00), ToInvariantString(format,
m01), ToInvariantString(format,
m02), ToInvariantString(format,
m10), ToInvariantString(format,
m11), ToInvariantString(format,
m12), ToInvariantString(format,
m20), ToInvariantString(format,
m21), ToInvariantString(format,
m22));
327 private string ToInvariantString(
string format,
float val)
329 return val.ToString(format, CultureInfo.InvariantCulture.NumberFormat);
334 return base.GetHashCode();
bool Equals(Matrix3 other)
Vector3 GetRow(int index)
void SetRow(int index, Vector3 row)
Vector3 GetColumn(int index)
static Matrix3 Rotate(Quaternion q)
static Matrix3 operator*(Matrix3 lhs, Matrix3 rhs)
Matrix3(Vector3 column0, Vector3 column1, Vector3 column2)
static bool operator==(Matrix3 lhs, Matrix3 rhs)
override string ToString()
override bool Equals(object other)
static Matrix3 Scale(Vector3 vector)
override int GetHashCode()
void SetColumn(int index, Vector3 column)
Vector3 MultiplyVector(Vector3 vector)
static bool operator!=(Matrix3 lhs, Matrix3 rhs)
string ToString(string format)
Matrix3(float d00, float d01, float d02, float d10, float d11, float d12, float d20, float d21, float d22)
override bool Equals(object other)