Add line perpedincular to existing line

Hello all,

Probably an easy question regarding rhino.python but after a few hours I am still not able to do it.
I have a slanted line and i would like to add line perpendicular to the existing line.
Can you please give me some hints how this can be done?

In screenshot above the black line is the “existing” line and the red one is the one i would like to draw.

Find the tangent direction on the curve at the point you want to add it. Take the vector outer (cross) product of the tangent direction with the cplane normal. This is the direction of the line.

Thank menno.
I do this by using the following command:
crv_vector = rs.VectorCreate(points_on_crv[0], points_on_crv[-1])

However, i haven’t figure yet with which command i can draw a line with a starting point and a vector. Any idea?

I guess something like

crv_tan = rs.VectorCreate(points_on_crv[0], points_on_crv[1])
crv_per = rs.VectorCrossProduct(rs.VectorCreate(0,0,1), crv_tan)

len = 10
rs.AddLine(points_on_crv[0], points_on_crv[0] + crv_per*len)

VectorCreate is not the way to go (stupid Python) but I hope you understand that I want to take the cross product of the (0,0,1) vector and the tangential vector.

does this pseudocode help?

end_pt = start_pt + vector



Great I did it!
@menno, @Willem thank you

#Create Vector
crv_vector = rs.VectorCreate(points_on_crv[0], points_on_crv[-1])
crv_normal_plane = rs.CurveNormal(crv)
crv_vector_normal_to_crv = rs.VectorCrossProduct(crv_vector,crv_normal_plane)
rs.AddLine(points_on_crv[0], points_on_crv[0] + rs.VectorUnitize(crv_vector_normal_to_crv)*von_mises_values[0])

This is how i finally did it. I think i could have skipped a step but it does the work!