I own an Apple II and am working on a program that uses hi-res graphics. I'm trying to use SIN and COS to draw a line from the vertex of a circle to a point on its circumference. Here's my program:
10 HGR 20 HCOLOR = 7 30 HPLOT 140, 70 TO 40 * COS(45) + 140, 40 * SIN(45) + 70
This should draw a line from the point (140,70) to another point 40 pixels away at an angle of 45 degrees. It doesn't.
You have the right idea, but most computers don't do their trig functions in degrees—they do them in radians. To convert from degrees to radians, multiply by pi (3.14159265) and divide by 180 (or, equivalently, just divide by 0.017453312). Here is a corrected version of your program:
10 HGR 20 HCOLOR = 7 25 PI = 3.14159265 30 HPLOT 140,70 TO 140 - 40 * COS (45 * PI/180),70 - 40 * SIN(45 * PI/180)