Finding an angle with 3 CGPoints

前端 未结 5 1034
长情又很酷
长情又很酷 2021-01-03 14:27

In my application, a user taps 3 times and an angle will be created by the 3 points that were tapped. It draws the angle perfectly. I am trying to calculate the angle at the

5条回答
  •  死守一世寂寞
    2021-01-03 14:36

    The way I have done it is to calculate the two angles separately using atan2(y,x) then using this function.

    static inline double
    AngleDiff(const double Angle1, const double Angle2)
    {
        double diff = 0;
        diff = fabs(Angle1 - Angle2);
        if (diff > ) {
            diff = (<2Pi>) - diff;
        }
        return diff;
    }
    

    The function deals in radians, but you can change to 180 and <2Pi> to 360

提交回复
热议问题