Skip to content

Commit bc63558

Browse files
authored
Update 722-math-cos.markdown
1 parent 9c66bfa commit bc63558

File tree

1 file changed

+30
-45
lines changed

1 file changed

+30
-45
lines changed

_build/reference/722-math-cos.markdown

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
# COS
22

3-
> COS (x)
3+
> f = COS (x)
44
5-
Cosine.
5+
Cosine of `x`. `x` is in radians.
6+
7+
### Example 1
68

79
```
810
a = cos(0.5)
9-
print a
11+
print a ' Output: 0.87758256189037
1012
1113
b = acos(a)
12-
print b
14+
print b ' Output: 0.5
1315
```
1416

15-
See SIN, TAN and ATAN.
17+
### Example 2
1618

17-
~~~
19+
```
1820
1921
'TRIG lesson one.bas SmallBASIC 0.12.2 [B+=MGA] 2016-03-12
2022
'note: the lines in the diagram have been thickened to help see and identify the color
@@ -109,59 +111,42 @@ at 0,0
109111
?"press any for first screen again..."
110112
pause
111113
wend
114+
```
112115

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
116117

117-
~~~
118+
At an angle around a given point, SIN and COS and radius (or distance) can locate the absolute screen x,y coordinate.
118119

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
123125
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
125127
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
127129
CIRCLE cx,cy,2,1,15
128130
r=200 'the radius or distance in pixels from cx,cy desired
129131
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)
132134
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
142143
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
157144
sub legend
158145
at 0,0
159146
?"green = leg adj, blue =leg opp, red = hypotenuse = radius"
160147
?"white square is where the right angle is, yellow arcs mark angle in question
161148
?"COS(yellow) = adj/hyp = green/red, red is radius of circle
162149
?"SIN(yellow) = opp/hyp = blue/red, red is radius of circle
163-
end
164-
165-
~~~
166-
150+
end
151+
```
167152

0 commit comments

Comments
 (0)