How can I align the tilt of a GN generated curve to the nearest surface normal of a target?

To simplify some modelling tasks (like hair), I would like to align the tilt of a curve to the nearest surface normal of some other object.

Here's what I get if I just shrinkwrap a mesh line to an object and generate a curve with GN:

Here's roughly what I would like it to look like:

I don't want to just shrinkwrap the geometry to the surface, because that would change edge lengths; I want to create a curve inside the geometry nodes that is aligned to the surface normals of the target object. I think this should be possible by comparing the direction that a +X vertex deformed by the curve points, as compared to the surface normal from a transfer attribute, and then offsetting the tilt by the angle between those two vectors, but I'm having trouble wrapping my brain around how to get that done in GN.

• just a dumb question: do we get this information at all? i mean the angle/surface normal of the target. I just can think of proximity node, but it just provides distance and position. But no normal info.... Feb 2 at 16:00
• ok...possible with raycast...but then it gets complicated....😫 Feb 2 at 16:01
• @Chris We can get the nearest surface normal with a "transfer attribute" node, with a normal node plugged into the attribute we want. It's okay that basic curves don't have normals-- this attribute is just a field, a virtual attribute that we can use for math on attributes that the curve does have, like tilt. Feb 2 at 16:05
• thank you! that question could keep me busy for days ....🤭 Feb 2 at 16:15