05-14-2005, 03:55 PM
Vector math works best though.
|a + b| = |a||b|cos(alpha)
Now to split this into cartesian components after this:
alpha = ArcCos(|a + b| / |a||b|)
:
alpha = ArcCos(Sqr((a.x + b.x) * (a.x + b.x) + (a.y + b.y) * (a.y + b.y)) / Sqr(a.x * a.x + a.y * a.y) / Sqr(b.x * b.x + b.y * b.y))
Make sure there's no division by zero.
|a + b| = |a||b|cos(alpha)
Now to split this into cartesian components after this:
alpha = ArcCos(|a + b| / |a||b|)
:
alpha = ArcCos(Sqr((a.x + b.x) * (a.x + b.x) + (a.y + b.y) * (a.y + b.y)) / Sqr(a.x * a.x + a.y * a.y) / Sqr(b.x * b.x + b.y * b.y))
Make sure there's no division by zero.