/* Read http://z0b.kapsi.fi/snippets.php before using this code. Thank you. */ // 'baseX' and 'baseY' is the common end on both lines, // x1/x2/y1/y2 are other endpoints float angleBetweenLines(const float baseX, const float baseY, const float x1, const float y1, const float x2, const float y2) { float a1 = (atan2(y2 - baseY, x2 - baseX)) * 57.29578122f, a2 = (atan2(y1 - baseY, x1 - baseX)) * 57.29578122f; a1 = fmod(a1 + 180.0f, 360.0f); a2 = fmod(a2 + 180.0f, 360.0f); return fmod((360.0f - a2) + a1, 360.0f); }