Given a point on a cartesian coordinate plane (x1, y1), a slope (m), and a length (n), how would I go about calculating the two possible points (x2, y2) and (x3, y3) that consist of the endpoints of the line segment without using trig. functions?
I know I can do this:
if (m < 0) k = arctan(m) + PI else k = arctan(m)
q = n / 2 r = q * cos(k) s = q * sin(k) x2 = x1 + r y2 = y1 + s x3 = x1 - r y3 = y1 - s
That gets it down to three trig. functions, two multiplies, and one divide (addition and subtraction doesn't matter). Anyone know of a way to do this that doesn't involve trig. or Newton's method? It _can_ be an approximation, but it needs to be accurate to at least 5 decimal places and computationally simple in all circumstances.