假设左上角为(0,0),给定一个30度的角度,起始点为(0,300),线长为600,如何计算出直线的结束点,以便直线代表所给定的角度。
C伪代码如下:
C伪代码如下:
main() {
int x,y;
getEndPoint(30, 600, 0, 300, &x, &y);
printf("end x=%d, end y=%d", x, y);
}
// input angle can be from 0 - 90 degrees
void getEndPoint(int angle, int len, int start_x, int start_y, int *end_x, int *end_y)
{
calculate the endpoint here for angle and length
*end_x = calculated_end_x;
*end_y = calculated_end_y;
}
r = d * PI / 180.0
。 - Clifford