Hello all,
I am just confused about the difference between the Transform.ChangePlane vs the Transform.PlaneToPlane.
Under the hood, this is what we have:
//
// Summary:
// Computes a change of basis transformation. A basis change is essentially a remapping
// of geometry from one coordinate system to another.
//
// Parameters:
// plane0:
// Coordinate system in which the geometry is currently described.
//
// plane1:
// Target coordinate system in which we want the geometry to be described.
//
// Returns:
// A transformation matrix which orients geometry from one coordinate system to
// another on success. Transform.Unset on failure.
public static Transform ChangeBasis(Plane plane0, Plane plane1)
{
Transform xf = Identity;
if (!UnsafeNativeMethods.ON_Xform_PlaneToPlane(ref xf, ref plane0, ref plane1, rotation: false))
{
return Unset;
}
return xf;
}
//
// Summary:
// Create a rotation transformation that orients plane0 to plane1. If you want to
// orient objects from one plane to another, use this form of transformation.
//
// Parameters:
// plane0:
// The plane to orient from.
//
// plane1:
// the plane to orient to.
//
// Returns:
// The translation transformation if successful, Transform.Unset on failure.
public static Transform PlaneToPlane(Plane plane0, Plane plane1)
{
Transform xf = Identity;
UnsafeNativeMethods.ON_Xform_PlaneToPlane(ref xf, ref plane0, ref plane1, rotation: true);
return xf;
}
Both are calling the same native method, with the difference of the rotation being true or false. So I did the following simple code:
// Test:
Plane ptest = new Plane(
new Point3d(50, 50, 50),
//Point3d.Origin,
new Vector3d(StaticExtension.random.NextDouble(), StaticExtension.random.NextDouble(), StaticExtension.random.NextDouble()));
Transform planetoplane = Transform.PlaneToPlane(Plane.WorldXY, ptest);
Transform changebasis = Transform.ChangeBasis(ptest, Plane.WorldXY);
Point3d p_planetoplane = new Point3d(StaticExtension.random.NextDouble(), StaticExtension.random.NextDouble(), StaticExtension.random.NextDouble());
Point3d p_changebasis = p_planetoplane;
p_planetoplane.Transform(planetoplane);
p_changebasis.Transform(changebasis);
This is what I see in the debug window:
If you canât see, note:
1- The Transform objects returned have the same values in the matrix. THE SAME. Even planetoplane == changebasis.
2- Well, then obviously the point transformed results are the sameâŚ
Is this really the expected behaviour? Is this a special case of some sort?
The description of the methods is ultra confusing, specially because BOTH versions have from/to, and they return the same matrix but in one case my ptest is the from and in the other it is the to.
+++++
From my tests, say you have something like a planar curve that you draw programatically on the WorldXY so that it is easier, then you want to orient it to at a given plane targetplane.
In this case, you may either - they are the same transformation
Transform.PlaneToPlane(Plane.WorldXY, targetPlane) - This one makes sense because the curve is on the WorldXY and you want it to be in the targetPlane. From/To are ok.
Transform.ChangeBasis(targetPlane, Plane.WorldXY) - Could you please help me understand what is going from the targetPlane to the WorldXY in this case?
Thanks!