Rhino Common - Matrix align block with curve

Hi,

I need to align the red shaped block on the blue line, so that then I can use sweep2 and basically flow the block along 2 rails.
However I am having troubles using Rotation Matrix to align the block to the blue curve, how would you go about that?

traccia2 = traccia1.OffsetNormalToSurface(srf, hprof*-1); //this is the blue curve
var idef = doc.InstanceDefinitions.Find(name, true);
Guid profilo2dguid = doc.Objects.AddInstanceObject(idef.Index, xform);

what are you trying to do ?
is curve.OffsetNormalToSurface the correct function ?
it is the same as OffsetNormal I think:
https://docs.mcneel.com/rhino/7/help/en-us/index.htm#commands/offsetnormal.htm

where is the insertpoint of the red curve / block ?
maybe post the corresponding .3dm file ?

Hi,
I’ve already done everything, it does insert the block in the correct position as shown in the screenshot, and does normal offset to srf in order to obtain the red curve.
Now I want to orient the blue object, so that it’s direction is the same as the red curve, basically rotate it in this case, however what I want to do is : to orient the blue shape (block) as shown by the grey curve and red curve. Thank you in advance for your help

look above

looks like a plane to plane transformation is what might help you.
Get the Starting and Target Plane with for example:

get the transformation:

1 Like

Actual working solution im satisfied with if anyone has the same issue

        public void RotateObject(Surface superficie, Surface srf, Point3d point,Curve joined)
        {
            Surface curve = superficie;
            // Get the normal at the specified point
            Point3d closestPoint;
            double u, v;
            if (!srf.ClosestPoint(point, out u, out v)) return;
            Vector3d normal = srf.NormalAt(u, v);
            Vector3d normalcrv = curve.NormalAt(u, v);

            // Calculate the angle of rotation to align with the normal
            double angle = Vector3d.VectorAngle(normalcrv, normal);
            // Convert the angle from degrees to radians
            angle = angle * (Math.PI / 180);

            // Rotate the curve to align with the normal
            curve.Rotate(angle,normalcrv, point);
            
        }