iphone - Find Angle between 2 polylines -
i drawing mkpolylines between 2 sets of coordinates on mkpolylineview in mkmapview. 1 line actual route travelled 1 point other, while other line shortest distance between 2 points. have drawn 2 sets of lines. need find angle direction in between 2 lines. despite efforts have not been able come helpful. needed.
this how have drawn polylines.
self.routeline = [mkpolyline polylinewithcoordinates:pointstouse count:[array count]]; self.straightline = [mkpolyline polylinewithcoordinates:straightlinepoints count:2]; [self.map addoverlay:self.routeline]; [self.map addoverlay:self.straightline]; - (mkoverlayview *)mapview:(mkmapview *)mapview viewforoverlay:(id <mkoverlay>)overlay { if(overlay == self.routeline){ // ylineview *polylineview = [[mkpolylineview alloc] initwithpolyline:self.polyline]; polylineview = [[mkpolylineview alloc] initwithpolyline:self.routeline]; polylineview.linewidth = 2; polylineview.strokecolor = [uicolor lightgraycolor]; polylineview.backgroundcolor = [uicolor graycolor]; return polylineview; } else{ polylineview = [[mkpolylineview alloc] initwithpolyline:self.straightrouteline]; polylineview.linewidth = 2; polylineview.strokecolor = [uicolor redcolor]; polylineview.backgroundcolor = [uicolor redcolor]; return polylineview; } }
i wrote code in python. can post code later when home, looks this:
angle = atan2(y2 - y1, x2 - x1) * 180 / pi;
Comments
Post a Comment