Search code examples
mathtrigonometryalgebrapi

Getting theta of Line Equation


Please forgive my lack of knowledge, which i think it's one of those basic formula related to Trigonometry.

Let's look at visual example: enter image description here

I have 5 lines, with their line equation (let's say they have zero offset ok)
how can i calculate the Theta of each line equation make (in Pi)?

also I have seen this: enter image description here

Are they generated from Theta of line equations? or it's another theory which help to find the theta?
much appreciate your time and effort


Solution

  • For equation

    y = k * x
    
    tg(Theta) = k 
    

    and

    Theta = Arctg(k) //arctangent function
    

    General line equation

    A * x + B * y + C = 0
    

    (It is more general than y=ax+b and includes cases of vertical and horizontal lines)

    Theta = atan2(A, B)
    

    (function atan2 or ArcTan2 exists in math libraries of many programming languages)