I am currently working on a project of drawing thick polylines and I am usin interpolation. I managed to calculate all the necessary points but I need to draw two more points. I need to translate one point normally to the line connecting two points. The scatch below shows what are the points. Naimely point L is to be translated for the distance between L and Jn normally to the line AB (B is the central point). Similar thing is with translation to the Kn.
I have written the code:
float alpha = atan2( B.y - A.y,B.x - A.x) - deg90;
float alpha2 = atan2( C.y - B.y, C.x - B.x) - deg90;
nJ.x = L.x + w*cos(alpha); // w is distance between A1 and A2
nJ.y = L.y + w*sin(alpha);
nK.x = L.x + w*cos(alpha2);
nK.y = L.y + w*sin(alpha2);
The code works only for some points, not all. I need to fix + sing in above calculations of nJ and nK, but I do not know how.