# Transformation in local coordinates

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;
}``````

If you want to transform some from one coordinate system to another (e.g. from world xy-plane to construction plane or vise versa), then create a change of basis transformation - `Transform.ChangeBasis`.

I think what I am doing is applying an xform relative to a local plane. But since the transform function acts in world, I have to stack them? I could try change basis but it doesnâ€™t sound like the same thing.