[MSCE U17 C#] Transform coordinates

Hi,

It has been a while since I worked with transformations so I will need some help.

I want to transform coordinates from world coordinates to a local coordinat system aligned with the green line with origo at the start of the line.

When transforming the middle coordinat from global to local the transformed point should read 0, 5.

I thought I could to something like this but it wont work.

DSegment3d segment = new DSegment3d(lineStartPoint, lineEndPoint);

DMatrix3d rotMatrix = DMatrix3d.XYRotation(segment.UnitTangent.AngleXY);

Dtransform3d transMatrix = DTransform3d.FromMatrixAndFixedPoint(rotMatrix, lineStartPoint);

// Now get the local coordinate
transMatrix.Multiply(out transformedPoint, middlePoint);

Best regards,

Krister