Was going through some methods and came across this one. I recently saw a comment referring to not performing sequential transformations, and instead multiplying them first. This is a method I use extensively, and I am wondering if it can be made more efficient? Basically it takes a plane, and a transform given in the local coords of that plane, and returns the transformed plane. The only way I have solved this is to transform the plane to world, xform it by the relative, and transform it back the inverse of the first.
public static Plane TransformPlaneRelative(Plane plane, Transform xform)
{
Transform xformToWorld = Transform.PlaneToPlane(plane, Plane.WorldXY);
plane.Transform(xformToWorld);
plane.Transform(xform);
Transform invXform;
xformToWorld.TryGetInverse(out invXform);
plane.Transform(invXform);
return plane;
}
edit: well, I guess I should have tried harder. This works as well, and I doubt it can get much faster(but please comment if you have thoughts)
public static Plane TransformPlaneRelative(Plane plane, Transform xform)
{
Transform xformToWorld = Transform.PlaneToPlane(plane, Plane.WorldXY);
Transform invXform = Transform.PlaneToPlane(Plane.WorldXY, plane);
plane.Transform(invXform * xform * xformToWorld);
return plane;
}