Search code examples
pythonpolar-coordinates

How to calculate angle between 3 polar coordinate points?


FY00 = [0, 0]

FY01 = [100, 0]

FY02 = [98, 40.10]

I have 3 points like this, first param is ρ, second param is θ, I want calculate ∠FY00-FY01-FY02 using python, how to do that?


Solution

  • Do you have a problem with the math or with the implementation?

    For the former, for any point (ρ, θ), you can translate to Cartesian coordinates via

    x = ρ cosθ
    y = ρ sinθ
    

    Once you get the Cartesian coordinates of all three points, you get the vectors

    v = B - A
    u = C - A
    

    where A are the coordinates of the vertex of the angle. Finally, after you have the vectors v and u, you simply write

    ∠BAC = arccos[(u.v)/|u||v|]
    

    For the latter, well, post your attempts and ask why they're not working.