If you have 3 points and you want to calculate the angle between them, this is a quick and correct way to calculate the value of the right angle:
double AngleBetweenThreePoints(CGPoint pointA, CGPoint pointB, CGPoint pointC) { CGFloat a = pointB.x - pointA.x; CGFloat b = pointB.y - pointA.y; CGFloat c = pointB.x - pointC.x; CGFloat d = pointB.y - pointC.y; CGFloat atanA = atan2(a, b); CGFloat atanB = atan2(c, d); return atanB - atanA; }
This will work for you if you indicate a point on one of the lines, an intersection point, and a point on another line.
source share