|
1 | 1 | # COS |
2 | 2 |
|
3 | | -> COS (x) |
| 3 | +> f = COS (x) |
4 | 4 |
|
5 | | -Cosine. |
| 5 | +Cosine of `x`. `x` is in radians. |
| 6 | + |
| 7 | +### Example 1 |
6 | 8 |
|
7 | 9 | ``` |
8 | 10 | a = cos(0.5) |
9 | | -print a |
| 11 | +print a ' Output: 0.87758256189037 |
10 | 12 |
|
11 | 13 | b = acos(a) |
12 | | -print b |
| 14 | +print b ' Output: 0.5 |
13 | 15 | ``` |
14 | 16 |
|
15 | | -See SIN, TAN and ATAN. |
| 17 | +### Example 2 |
16 | 18 |
|
17 | | -~~~ |
| 19 | +``` |
18 | 20 |
|
19 | 21 | 'TRIG lesson one.bas SmallBASIC 0.12.2 [B+=MGA] 2016-03-12 |
20 | 22 | 'note: the lines in the diagram have been thickened to help see and identify the color |
@@ -109,59 +111,42 @@ at 0,0 |
109 | 111 | ?"press any for first screen again..." |
110 | 112 | pause |
111 | 113 | wend |
| 114 | +``` |
112 | 115 |
|
113 | | -~~~ |
114 | | - |
115 | | -At an angle around a given point, SIN and COS and radius (or distance) can locate the absolute screen x,y coordinate: |
| 116 | +### Example 3 |
116 | 117 |
|
117 | | -~~~ |
| 118 | +At an angle around a given point, SIN and COS and radius (or distance) can locate the absolute screen x,y coordinate. |
118 | 119 |
|
119 | | -''' Diagrammed SIN and COS.bas SmallBASIC 0.12.2 [B+=MGA] 2016-03-16 |
120 | | -''' ah finally got diagramed analysis built into single quote commented code!!! |
121 | | -''' the color codes match original Trig lesson one |
122 | | -'''reminder XMAX, YMAX and PI are built in constants |
| 120 | +``` |
| 121 | +' Diagrammed SIN and COS.bas SmallBASIC 0.12.2 [B+=MGA] 2016-03-16 |
| 122 | +' ah finally got diagramed analysis built into single quote commented code!!! |
| 123 | +' the color codes match original Trig lesson one |
| 124 | +' reminder XMAX, YMAX and PI are built in constants |
123 | 125 | CONST green =RGB(0,128,0) |
124 | | -''' a central point cx,cy around which to draw |
| 126 | +' a central point cx,cy around which to draw |
125 | 127 | cx=XMAX/2:cy=YMAX/2 'again cx,cy can be anywhere on screen so dont make them constant |
126 | | -'''highlight center |
| 128 | +' highlight center |
127 | 129 | CIRCLE cx,cy,2,1,15 |
128 | 130 | r=200 'the radius or distance in pixels from cx,cy desired |
129 | 131 | CIRCLE cx,cy,r,1,8 'we want a point somewhere on this circle, radius = constant distance away from point |
130 | | -''' locate point 30 degrees and r distance from cx,cy 30 degrees = PI/6 radians |
131 | | -''' here is 30 degrees in tiny purple circle around x=r*cos(rad(30),y=r*sin(rad(30) |
| 132 | +' locate point 30 degrees and r distance from cx,cy 30 degrees = PI/6 radians |
| 133 | +' here is 30 degrees in tiny purple circle around x=r*cos(rad(30),y=r*sin(rad(30) |
132 | 134 | CIRCLE cx + r*COS(RAD(30)), cy + r*SIN(RAD(30)), 3, 1, 13 'x,y,r=3,aspect=1,color 13 |
133 | | -''' uncomment single comment lines for analysis |
134 | | -'legend |
135 | | -'LINE cx,cy,cx+r*COS(RAD(30)),cy,green 'adjacent leg in red |
136 | | -'LINE cx+r*COS(RAD(30)),cy,cx+r*COS(RAD(30)),cy + r*SIN(RAD(30)),9 'leg opposite in blue |
137 | | -'LINE cx,cy,cx+r*COS(RAD(30)),cy + r*SIN(RAD(30)),12 |
138 | | -'RECT cx+r*COS(RAD(30))-11,cy+2 step 9,9,15 |
139 | | -'''' V there are 12, 30 degree angles in circle (2*PI) so 2*PI/12 or PI/6 |
140 | | -'ARC cx,cy,30,0,PI/6,1,14 |
141 | | -'ARC cx,cy,35,0,RAD(30),1,14 |
| 135 | +legend |
| 136 | +LINE cx,cy,cx+r*COS(RAD(30)),cy,green 'adjacent leg in red |
| 137 | +LINE cx+r*COS(RAD(30)),cy,cx+r*COS(RAD(30)),cy + r*SIN(RAD(30)),9 'leg opposite in blue |
| 138 | +LINE cx,cy,cx+r*COS(RAD(30)),cy + r*SIN(RAD(30)),12 |
| 139 | +RECT cx+r*COS(RAD(30))-11,cy+2 step 9,9,15 |
| 140 | +' V there are 12, 30 degree angles in circle (2*PI) so 2*PI/12 or PI/6 |
| 141 | +ARC cx,cy,30,0,PI/6,1,14 |
| 142 | +ARC cx,cy,35,0,RAD(30),1,14 |
142 | 143 |
|
143 | | -''' Another example at 240 degrees = 4*PI/3 radians |
144 | | -''' here is 60+180=240 degrees in yellow both x and y are neg in relation to cx,cy |
145 | | -'CIRCLE cx + r*COS(RAD(240)), cy + r*SIN(RAD(240)), 3, 1, 14 'yellow |
146 | | -'''uncomment single comment lines for analysis |
147 | | -'legend |
148 | | -'LINE cx,cy,cx+r*COS(RAD(240)),cy,green 'adjacent leg in red |
149 | | -'LINE cx+r*COS(RAD(240)),cy,cx+r*COS(RAD(240)),cy + r*SIN(RAD(240)),9 'leg opposite in blue |
150 | | -'LINE cx,cy,cx+r*COS(RAD(240)),cy + r*SIN(RAD(240)),12 |
151 | | -'RECT cx+r*COS(RAD(240))+2,cy-11 step 9,9,15 |
152 | | -'''240 degrees =180 + 60 = PI + 2*PI/6 = PI+PI/3 = 4*PI/3 radians |
153 | | -''' V end angle for arc in radians = RAD(240) or 4*PI/3 radians |
154 | | -'ARC cx,cy,15,0,4*PI/3,1,14 |
155 | | -'ARC cx,cy,10,0,RAD(240),1,14 |
156 | | -PAUSE |
157 | 144 | sub legend |
158 | 145 | at 0,0 |
159 | 146 | ?"green = leg adj, blue =leg opp, red = hypotenuse = radius" |
160 | 147 | ?"white square is where the right angle is, yellow arcs mark angle in question |
161 | 148 | ?"COS(yellow) = adj/hyp = green/red, red is radius of circle |
162 | 149 | ?"SIN(yellow) = opp/hyp = blue/red, red is radius of circle |
163 | | -end |
164 | | -
|
165 | | -~~~ |
166 | | - |
| 150 | +end |
| 151 | +``` |
167 | 152 |
|
0 commit comments