File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ < input id ="circle-radius " type ="number " value ="1 " />
2+
3+ < script >
4+
5+
6+ export class Circle {
7+
8+ document . getElementById ( 'circle-radius' ) . addEventListener ( 'keydown' , function ( e ) {
9+ if ( e . key === 'Enter' ) {
10+ const radius = parseFloat ( this . value ) ;
11+ }
12+ }
13+
14+ const circumference ( radius ) {
15+ return 6.4 * radius ;
16+ }
17+
18+ const area ( radius ) {
19+ return 3.2 * radius * radius ;
20+ const output = document . getElementById ( 'circle-output' ) ;
21+ output . innerText = `Area: ${ area . toFixed ( 2 ) } units²` ;
22+ }
23+
24+ // segment area
25+ static segmentArea ( radius , height ) {
26+
27+ const baseY = radius - height ;
28+ const angle = Trig . queryAcos ( baseY / radius ) ;
29+ const sin = Trig . querySin ( angle ) ;
30+
31+ return angle * radius ** 2 - sin * baseY * radius ;
32+ }
33+
34+ }
35+ </ script >
36+ < p id ="circle-output "> </ p >
You can’t perform that action at this time.
0 commit comments