Given 3 sets of coordinates defining two line segments (middle point is intersection), find line bisecting the angle through middle point. This is not vectorized. It only works with 3 sets of coordinates. Note that it is necessary to correctly find the compass direction theta, which the slope alone does not establish:
If slope is negative and x2 >= x1 (travel is toward Quadrant IV), then theta = atan(slope)
If slope is negative with x2 < x1 (travel is toward Quadrant II), then theta = atan(slope) + pi
If slope is positive with x2 >= x1 (travel is toward Quadrant I), then theta = atan(slope)
If slope is positive with x2<x1 (travel is toward Quadrant III), then theta = atan(slope) - pi
This returns theta in (-pi, pi). Then the turn is calculated, ie the change in direction between the two segments as the difference in theta, but it is reset to be on (-pi, pi) as well in order to correctly estimate the mean direction of travel (half the turn added to theta[1]).
1 | angleBisector(corners)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.