public FormILFMatrixCalculator(RotationMatrix matrix) { this.m_Device = null; this.m_Mesh = null; this.m_Paused = false; InitializeComponent(); this.m_FormRenderSurface = new FormILFRenderSurface(); this.panelRenderSurface.Controls.Add(this.m_FormRenderSurface); this.m_FormRenderSurface.Visible = true; if (!this.InitializeGraphics()) { MessageBox.Show("Failed to initialize Direct3D.", "TRE Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error); } EulerAngles eulerAngles = matrix.ToEulerAngles(); this.trackBarXPitch.Value = eulerAngles.xPitch; this.trackBarYYaw.Value = eulerAngles.yYaw; this.trackBarZRoll.Value = eulerAngles.zRoll; this.m_OriginalXPitch = eulerAngles.xPitch; this.m_OriginalYYaw = eulerAngles.yYaw; this.m_OriginalZRoll = eulerAngles.zRoll; this.UpdateMatrix(); }
public EulerAngles(RotationMatrix rotationMatrix) { EulerAngles eulerAngles = rotationMatrix.ToEulerAngles(); this.m_xPitch = eulerAngles.xPitch; this.m_yYaw = eulerAngles.yYaw; this.m_zRoll = eulerAngles.zRoll; }
private void UpdateIlfAngles(RotationMatrix rotationMatrix) { EulerAngles eulerAngles = new EulerAngles(rotationMatrix); this.textBoxIlfPitch.Text = ((eulerAngles.xPitch > 0) ? "+" : String.Empty) + eulerAngles.xPitch + "°"; this.textBoxIlfRoll.Text = ((eulerAngles.zRoll > 0) ? "+" : String.Empty) + eulerAngles.zRoll + "°"; this.textBoxIlfYaw.Text = ((eulerAngles.yYaw > 0) ? "+" : String.Empty) + eulerAngles.yYaw + "°"; }
public RotationMatrix ToMatrix() { RotationMatrix returnValue = new RotationMatrix(); Single xPitch = Geometry.DegreeToRadian(this.xPitch); Single yYaw = Geometry.DegreeToRadian(this.yYaw); Single zRoll = Geometry.DegreeToRadian(this.zRoll); returnValue[0][0] = (Single)(Math.Cos(yYaw) * Math.Cos(zRoll) + Math.Sin(yYaw) * Math.Sin(xPitch) * Math.Sin(zRoll)); returnValue[0][1] = (Single)(-Math.Cos(yYaw) * Math.Sin(zRoll) + Math.Sin(yYaw) * Math.Sin(xPitch) * Math.Cos(zRoll)); returnValue[0][2] = (Single)(Math.Sin(yYaw) * Math.Cos(xPitch)); returnValue[1][0] = (Single)(Math.Cos(xPitch) * Math.Sin(zRoll)); returnValue[1][1] = (Single)(Math.Cos(xPitch) * Math.Cos(zRoll)); returnValue[1][2] = (Single)(-Math.Sin(xPitch)); returnValue[2][0] = (Single)(-Math.Sin(yYaw) * Math.Cos(zRoll) + Math.Cos(yYaw) * Math.Sin(xPitch) * Math.Sin(zRoll)); returnValue[2][1] = (Single)(Math.Sin(yYaw) * Math.Sin(zRoll) + Math.Cos(yYaw) * Math.Sin(xPitch) * Math.Cos(zRoll)); returnValue[2][2] = (Single)(Math.Cos(yYaw) * Math.Cos(xPitch)); return returnValue; }
public static RotationMatrix operator *(RotationMatrix matrix1, RotationMatrix matrix2) { RotationMatrix returnValue = new RotationMatrix(); returnValue[0][0] = (matrix1[0][0] * matrix2[0][0]) + (matrix1[0][1] * matrix2[1][0]) + (matrix1[0][2] * matrix2[2][0]); returnValue[0][1] = (matrix1[0][0] * matrix2[0][1]) + (matrix1[0][1] * matrix2[1][1]) + (matrix1[0][2] * matrix2[2][1]); returnValue[0][2] = (matrix1[0][0] * matrix2[0][2]) + (matrix1[0][1] * matrix2[1][2]) + (matrix1[0][2] * matrix2[2][2]); returnValue[1][0] = (matrix1[1][0] * matrix2[0][0]) + (matrix1[1][1] * matrix2[1][0]) + (matrix1[1][2] * matrix2[2][0]); returnValue[1][1] = (matrix1[1][0] * matrix2[0][1]) + (matrix1[1][1] * matrix2[1][1]) + (matrix1[1][2] * matrix2[2][1]); returnValue[1][2] = (matrix1[1][0] * matrix2[0][2]) + (matrix1[1][1] * matrix2[1][2]) + (matrix1[1][2] * matrix2[2][2]); returnValue[2][0] = (matrix1[2][0] * matrix2[0][0]) + (matrix1[2][1] * matrix2[1][0]) + (matrix1[2][2] * matrix2[2][0]); returnValue[2][1] = (matrix1[2][0] * matrix2[0][1]) + (matrix1[2][1] * matrix2[1][1]) + (matrix1[2][2] * matrix2[2][1]); returnValue[2][2] = (matrix1[2][0] * matrix2[0][2]) + (matrix1[2][1] * matrix2[1][2]) + (matrix1[2][2] * matrix2[2][2]); return returnValue; }
private void UpdateMatrix() { this.rotationMatrix = new RotationMatrix(new EulerAngles(this.yYaw, this.xPitch, this.zRoll)); MatrixToDataGridView(this.rotationMatrix, this.dataGridViewMatrix); UpdateLabels(); this.m_FormRenderSurface.Invalidate(); }
private void MatrixToDataGridView(RotationMatrix matrix, DataGridView dataGridView) { dataGridView.Rows.Clear(); for (Int32 row = 0; row < 3; row++) { dataGridView.Rows.Add(new Object[] { matrix[row][0], matrix[row][1], matrix[row][2] }); } dataGridView.SelectAll(); }
private RotationMatrix DataGridViewToMatrix(DataGridView dataGridView) { RotationMatrix returnValue = new RotationMatrix(); for (Int32 row = 0; row < 3; row++) { for (Int32 column = 0; column < 3; column++) { returnValue[row][column] = (Single)dataGridView.Rows[row].Cells[column].Value; } } return returnValue; }