| Frame to Frame Rototranslation
| |
Info & Tags |
| |
| Article #: |
3 |
| Created: |
2010-02-09 |
| Modified: |
2010-05-19 |
| Tags: |
eyeshot3, transformation |
|
In many situations you want to rotate your imported model setting some specific planar face as the top one. It goes without saying that this rotation is foundamental in CAM applications where the model need to be properly oriented in respect to the milling Z axis.
The following code snippet demonstrates how to compute this transformation and how to apply it to a Quad entity.
| C# |
Point3D p1 = new Point3D(0, 0, 0);
Point3D p2 = new Point3D(100, 0, 0);
Point3D p3 = new Point3D(100, 20, 50);
Point3D p4 = new Point3D(0, 20, 50);
Quad q1 = new Quad(p1, p2, p3, p4);
mainViewport.Entities.Add(q1, 0, Color.DeepPink);
Plane dest = Plane.XY;
Plane source = new Plane(p1, p2, p3);
Transformation t = new Transformation();
t.Rotation(source, dest);
Quad q2 = (Quad) q1.Clone();
q2.TransformBy(t);
mainViewport.Entities.Add(q2, 0, Color.Blue); |
| Visual Basic |
Dim p1 As New Point3D(0, 0, 0)
Dim p2 As New Point3D(100, 0, 0)
Dim p3 As New Point3D(100, 20, 50)
Dim p4 As New Point3D(0, 20, 50)
Dim q1 As New Quad(p1, p2, p3, p4)
mainViewport.Entities.Add(q1, 0, Color.DeepPink)
Dim dest As Plane = Plane.XY
Dim source As New Plane(p1, p2, p3)
Dim t As New Transformation()
t.Rotation(source, dest)
Dim q2 As Quad = DirectCast(q1.Clone(), Quad)
q2.TransformBy(t)
mainViewport.Entities.Add(q2, 0, Color.Blue) |
|