File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1494,7 +1494,17 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
14941494 }
14951495
14961496 const ratio = 2 * height / length ;
1497-
1497+
1498+ // Segment validity check
1499+
1500+ if ( ratio === 1 ) {
1501+ document . getElementById ( 'segment-area' ) . innerText = 'If it is twice as long as high that is a semi-circle.' ;
1502+ return ;
1503+ }
1504+ if ( ratio > 1 ) {
1505+ document . getElementById ( 'segment-area' ) . innerText = 'A circle-segment is less than half as high as long.' ;
1506+ return ;
1507+ }
14981508
14991509 const angle = parseFloat ( 2 * Atan ( ratio ) ) ;
15001510 const sine = parseFloat ( sin ( angle ) ) ;
@@ -1780,7 +1790,18 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
17801790 document . getElementById ( 'cap-volume' ) . innerText = '' ;
17811791 return ;
17821792 }
1793+
1794+ // Cap validity check
17831795
1796+ if ( height === radius ) {
1797+ document . getElementById ( 'cap-volume' ) . innerText = 'If the radius equals the height that is a hemisphere.' ;
1798+ return ;
1799+ }
1800+
1801+ if ( height > radius ) {
1802+ document . getElementById ( 'cap-volume' ) . innerText = 'The height of a spherical cap is shorter than its radius.' ;
1803+ return ;
1804+ }
17841805
17851806 document . getElementById ( 'cap-volume' ) . innerText =
17861807 `Volume: ${ capVolume ( radius , height ) . toFixed ( 5 ) } cubic units` ;
You can’t perform that action at this time.
0 commit comments