public TransformMatrix(TransformMatrix other) { rotation = new Matrix33(other.rotation); scale = new Matrix33(other.scale); SetTransformed(); Position = new Vector3(other.Position.X, other.Position.Y, other.Position.Z); }
public TransformMatrix() { Position = new Vector3(0); scale = new Matrix33(); rotation = new Matrix33(); SetTransformed(); }
private void SetTransformed() { if (rotation != null && scale != null) { transformedMatrix = new Matrix33(rotation); transformedMatrix.M00 *= scale.M00; transformedMatrix.M11 *= scale.M11; transformedMatrix.M22 *= scale.M22; } }
private void SetTransformed() { if (rotation != null && scale != null) { transformedMatrix = new Matrix33(); transformedMatrix = rotation; transformedMatrix.M00 *= scale.X; transformedMatrix.M11 *= scale.Y; transformedMatrix.M22 *= scale.Z; } }
public Matrix33(Matrix33 other) { m00 = other.m00; m01 = other.m01; m02 = other.m02; m10 = other.m10; m11 = other.m11; m12 = other.m12; m20 = other.m20; m21 = other.m21; m22 = other.m22; }
public void ReadFromFile(BinaryReader reader) { Vector3 m1 = Vector3Extenders.ReadFromFile(reader); float x = reader.ReadSingle(); Vector3 m2 = Vector3Extenders.ReadFromFile(reader); float y = reader.ReadSingle(); Vector3 m3 = Vector3Extenders.ReadFromFile(reader); float z = reader.ReadSingle(); transformedMatrix = new Matrix33(m1, m2, m3); Decompose(); Position = new Vector3(x, y, z); }
public void ReadFromFile(MemoryStream reader, bool isBigEndian) { Vector3 m1 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float x = reader.ReadSingle(isBigEndian); Vector3 m2 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float y = reader.ReadSingle(isBigEndian); Vector3 m3 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float z = reader.ReadSingle(isBigEndian); transformedMatrix = new Matrix33(m1, m2, m3); Decompose(); Position = new Vector3(x, y, z); }
public static Matrix33 operator *(Matrix33 matrix1, Matrix33 matrix2) { Matrix33 matrix = new Matrix33(); matrix.m00 = matrix1.m00 * matrix2.m00; matrix.m01 = matrix1.m01 * matrix2.m01; matrix.m02 = matrix1.m02 * matrix2.m02; matrix.m10 = matrix1.m10 * matrix2.m10; matrix.m11 = matrix1.m11 * matrix2.m11; matrix.m12 = matrix1.m12 * matrix2.m12; matrix.m20 = matrix1.m20 * matrix2.m20; matrix.m21 = matrix1.m21 * matrix2.m21; matrix.m22 = matrix1.m22 * matrix2.m22; return(matrix); }
public static Matrix33 operator +(Matrix33 matrix1, Matrix33 matrix2) { Matrix33 matrix = new Matrix33(); matrix.m00 = matrix1.M00 + matrix2.m00; matrix.m01 = matrix1.M01 + matrix2.m01; matrix.m02 = matrix1.M02 + matrix2.m02; matrix.m10 = matrix1.M10 + matrix2.m10; matrix.m11 = matrix1.M11 + matrix2.m11; matrix.m12 = matrix1.M12 + matrix2.m12; matrix.m20 = matrix1.M20 + matrix2.m20; matrix.m21 = matrix1.M21 + matrix2.m21; matrix.m22 = matrix1.M22 + matrix2.m22; matrix.ToEuler(); return(matrix); }
private void Decompose() { //retrieve scale first. scale = new Vector3(); scale.X = (float)Math.Sqrt((Matrix.M00 * Matrix.M00) + (Matrix.M01 * Matrix.M01) + (Matrix.M02 * Matrix.M02)); scale.Y = (float)Math.Sqrt((Matrix.M10 * Matrix.M10) + (Matrix.M11 * Matrix.M11) + (Matrix.M12 * Matrix.M12)); scale.Z = (float)Math.Sqrt((Matrix.M20 * Matrix.M20) + (Matrix.M21 * Matrix.M21) + (Matrix.M22 * Matrix.M22)); //when we divide out the scale we just have the rotation left. Matrix33 rotation = new Matrix33(); rotation.M00 = Matrix.M00 / scale.X; rotation.M01 = Matrix.M01 / scale.X; rotation.M02 = Matrix.M02 / scale.X; rotation.M10 = Matrix.M10 / scale.Y; rotation.M11 = Matrix.M11 / scale.Y; rotation.M12 = Matrix.M12 / scale.Y; rotation.M20 = Matrix.M20 / scale.Z; rotation.M21 = Matrix.M21 / scale.Z; rotation.M22 = Matrix.M22 / scale.Z; this.rotation = rotation; }
public void ReadFromFile(BinaryReader reader) { Vector3 m1 = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); float x = reader.ReadSingle(); Vector3 m2 = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); float y = reader.ReadSingle(); Vector3 m3 = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); float z = reader.ReadSingle(); transformedMatrix = new Matrix33(m1, m2, m3); scale = new Matrix33(new Vector3(m1.Length(), 0.0f, 0.0f), new Vector3(0.0f, m2.Length(), 0.0f), new Vector3(0.0f, 0.0f, m3.Length())); rotation = new Matrix33(); transformedMatrix.M00 = transformedMatrix.M00 / scale.M00; transformedMatrix.M01 = transformedMatrix.M01 / scale.M00; transformedMatrix.M02 = transformedMatrix.M02 / scale.M00; transformedMatrix.M10 = transformedMatrix.M10 / scale.M11; transformedMatrix.M11 = transformedMatrix.M11 / scale.M11; transformedMatrix.M12 = transformedMatrix.M12 / scale.M11; transformedMatrix.M20 = transformedMatrix.M20 / scale.M22; transformedMatrix.M21 = transformedMatrix.M21 / scale.M22; transformedMatrix.M22 = transformedMatrix.M22 / scale.M22; Position = new Vector3(x, y, z); }
public void ReadFromFile(MemoryStream reader, bool isBigEndian) { Vector3 m1 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float x = reader.ReadSingle(isBigEndian); Vector3 m2 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float y = reader.ReadSingle(isBigEndian); Vector3 m3 = Vector3Extenders.ReadFromFile(reader, isBigEndian); float z = reader.ReadSingle(isBigEndian); transformedMatrix = new Matrix33(m1, m2, m3); scale = new Matrix33(new Vector3(m1.Length(), 0.0f, 0.0f), new Vector3(0.0f, m2.Length(), 0.0f), new Vector3(0.0f, 0.0f, m3.Length())); rotation = new Matrix33(); transformedMatrix.M00 = transformedMatrix.M00 / scale.M00; transformedMatrix.M01 = transformedMatrix.M01 / scale.M00; transformedMatrix.M02 = transformedMatrix.M02 / scale.M00; transformedMatrix.M10 = transformedMatrix.M10 / scale.M11; transformedMatrix.M11 = transformedMatrix.M11 / scale.M11; transformedMatrix.M12 = transformedMatrix.M12 / scale.M11; transformedMatrix.M20 = transformedMatrix.M20 / scale.M22; transformedMatrix.M21 = transformedMatrix.M21 / scale.M22; transformedMatrix.M22 = transformedMatrix.M22 / scale.M22; Position = new Vector3(x, y, z); }
public Matrix33(Matrix33 other) { Row1 = new Vector3(other.m00, other.m01, other.m02); Row2 = new Vector3(other.m10, other.m11, other.m12); Row3 = new Vector3(other.m20, other.m21, other.m22); }
public void SetRotationMatrix(Vector3 vector) { rotation = new Matrix33(); rotation.SetEuler(vector); SetTransformed(); }
public void SetScaleMatrix(Vector3 vector) { scale = new Matrix33(new Vector3(vector.X, 0.0f, 0.0f), new Vector3(0.0f, vector.Y, 0.0f), new Vector3(0.0f, 0.0f, vector.Z)); SetTransformed(); }