Directly using Transformation Matrix in HelixToolkit

Look! there's a flower!·2024년 8월 31일

You can get the final transformation matrix of TransformGroup3D and use it to calculate transformation directly.

// Create a transform group
Transform3DGroup transformGroup = new Transform3DGroup();

// Add some transformations
transformGroup.Children.Add(new TranslateTransform3D(1, 2, 3));
transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 45)));
transformGroup.Children.Add(new ScaleTransform3D(2, 2, 2));

// Get the final transformation matrix
Matrix3D finalMatrix = transformGroup.Value;

// Transform a point
Point3D originalPoint = new Point3D(1, 1, 1);
Point3D transformedPoint = finalMatrix.Transform(originalPoint);

// Transform a vector
Vector3D originalVector = new Vector3D(1, 1, 1);
Vector3D transformedVector = finalMatrix.Transform(originalVector);

// Using Transform3DGroup directly
Point3D transformedPoint2 = transformGroup.Transform(originalPoint);
Vector3D transformedVector2 = transformGroup.Transform(originalVector);

// Inverse transformation
Matrix3D inverseMatrix = finalMatrix.Inverse;
Point3D recoveredPoint = inverseMatrix.Transform(transformedPoint);
profile
Why don't you take a look around for a moment?

0개의 댓글