@@ -3075,25 +3075,25 @@ <h3 itemprop="eduQuestionType" style="margin:7px">Area of a Circle Segment</h3>
30753075
30763076 // Case 1: height + radius known → derive length
30773077 if ( ! isNaN ( h ) && ! isNaN ( r ) && isNaN ( l ) ) {
3078- let angle = Acos ( ( r - h ) / r ) ;
3079- l = 2 * r * sin ( angle ) ;
3080- lInput . value = l . toFixed ( 5 ) ;
3081- autoFilledField = "chord-length" ;
3082- }
3078+ // l was empty, so we auto-fill it
3079+ l = 2 * r * sin ( angle ) ;
3080+ lInput . value = l . toFixed ( 5 ) ;
3081+ autoFilledField = "chord-length" ;
3082+ }
30833083
3084- // Case 2: height + length known → derive radius
3085- if ( ! isNaN ( h ) && ! isNaN ( l ) && isNaN ( r ) ) {
3086- r = ( l ** 2 + 4 * h ** 2 ) / ( 8 * h ) ;
3087- rInput . value = r . toFixed ( 5 ) ;
3088- autoFilledField = "parent-radius" ;
3089- }
3084+ if ( ! isNaN ( h ) && ! isNaN ( l ) && isNaN ( r ) ) {
3085+ // r was empty, so we auto-fill it
3086+ r = ( l ** 2 + 4 * h ** 2 ) / ( 8 * h ) ;
3087+ rInput . value = r . toFixed ( 5 ) ;
3088+ autoFilledField = "parent-radius" ;
3089+ }
30903090
3091- // Case 3: length + radius known → derive height
3092- if ( ! isNaN ( l ) && ! isNaN ( r ) && isNaN ( h ) ) {
3093- h = r - Math . sqrt ( r ** 2 - ( l / 2 ) ** 2 ) ;
3094- hInput . value = h . toFixed ( 5 ) ;
3095- autoFilledField = "segment-height" ;
3096- }
3091+ if ( ! isNaN ( l ) && ! isNaN ( r ) && isNaN ( h ) ) {
3092+ // h was empty, so we auto-fill it
3093+ h = r - Math . sqrt ( r ** 2 - ( l / 2 ) ** 2 ) ;
3094+ hInput . value = h . toFixed ( 5 ) ;
3095+ autoFilledField = "segment-height" ;
3096+ }
30973097
30983098 // Validity check
30993099 if ( h > r || l < 2 * h || r < h ) {
0 commit comments