I am at the moment having some issues with computing an endpoint in a raster grid that is also a valid position in a graph. I am trying to draw a line between these two points, but as the point I am computing becomes negative, its position becomes invalid.
How do I compute the right endpoint value within a 20x20 matrix where my start point is $(10,10)$, and the endpoint has to be 10 steps away from the center at any angle?
This is how I compute the angle now:
coordinate endpoint(double angle, coordinate start, int lenght)
{
double radians = (M_PI/180)*angle;
double x2 = start.first + (lenght * cos(radians));
double y2 = start.second + (lenght * sin(radians));
return std::make_pair(round(x2),round(y2));
}