@dale @emilio @dave_stasiuk
Thank you all for your help.
I ended up using @emilio’s original suggestion of looking at the python file, and I converted the method to C# by using the methods already in RhinoCommon for C#.
It turned out that it wasn’t a big hassle after all, apart from the function calls v0.Unitize() and v1.Unitize(), i tried to look up what they did but had not luck, but as far as I have tested, the C# verion doesn’t need to unitize v0 and v1.
private PolylineCurve Orient(PolylineCurve Contour, Point3d FromPoint0, Point3d FromPoint1)
// Choose Target points.
// I use two points along the X-axis
// since I wanted my shape to align with the X-axis
Point3d ToPoint0 = new Point3d(0, 0, 0);
Point3d ToPoint1 = new Point3d(1, 0, 0);
Transform xform_move = Transform.Translation(ToPoint0 - FromPoint0);
Transform xform_scale = Transform.Identity;
var v0 = FromPoint1 - FromPoint0;
var v1 = ToPoint1 - ToPoint0;
Transform xform_rotate = Transform.Rotation(v0, v1, FromPoint0);
Transform xform_final = xform_move * xform_scale * xform_rotate;