I’m trying to draw a line segment, but knowing only the origin, the angle, and the length of the line. I’ve got something somewhat working already, but it doesn’t display the line at the correct angle, but at about 105 degrees greater (my trig is horrible). pseudocode:
Vector2 pos1 = new Vector2(10, 10);
double ang = 270;
double len = 20;
double adj = cos(ang) * len;
double opp = sqrt(len * len - adj * adj);
Vector2 pos2 = new Vector2(pos1.x + adj, pos1.y + opp);
drawLine(pos1, pos2);
Anyone have any advice to offer?
Most programming languages do trig in radians, not degrees. Convert your angles before using.