Get angle between 2 lines

I have 2 lines which are in the same layer, what I want to do is calculate the angle between the 2 lines. How could I do this in c#? I have the 2 Line objects within my code.
Is there a command or method I could use to get the angle between the 2 lines?

Below is an image of the 2 lines which I want to get the angle of.

Thank you

Hi Willy,

if both lines have share the same origin and are pointing away from this origin you could get their direction vectors (their tangents) and use them to calculate the angle using Rhino.Geometry.Vector3d.VectorAngle


Hi Clement,
Thanks for the quick reply.
I created the below piece of code with the info you have provided.

        Vector3d rightV = right.Direction; //right line
        Vector3d topV = top.Direction; //top line

        double test = Rhino.Geometry.Vector3d.VectorAngle(topV, rightV);

However, the angle which it generates is wrong, value I get is 2.059 but the actual angle is 62.
Have I done it wrong?


Hi Willy, there are 2 things to consider:

First, the angle the method returns is in radians, so you’ll need to convert it to degrees.
Second, if you do not provide a proper plane, it can be that you’ll get the reflex angle, which you have to subtract from 180 degrees. This seems to be the case here, 2.059 in radians equals 117.97201 degrees, once you subtract it from 180 you’ll get 62.0279 degrees.

You’ll might also try to use the method which allows to define a plane. Using a plane normal as a third vector technically allows to get a signed angle. The math behind should be something like below function, which is python btw:

def GetSignedAngle(Va, Vb, Vn):
    '''gets signed angle between Va and Vb, Vn is the plane normal'''

    # all vectors must be unitized 
    cross = Rhino.Geometry.Vector3d.CrossProduct(Va, Vb)
    # angle in radians
    return math.atan2(cross * Vn, Va * Vb)



Thanks a lot mate. It worked and thanks for the detailed explanation.