Names Default To Here( 1 ); // This script determines whether a basketball free-throw "swishes" through the rim or not. // Constants (English units) x0=0; // x location of center of ball at time 0, ft g=32.2; // acceleration due to gravity, fps2 dRim=18/12; // rim diameter, ft dBall=9.55/12; // ball diameter, ft xRimCtr=15-6/12-dRim/2; // x location of center of rim from launch point of ball, ft yRimCtr=10; // y location of center of rim above floor, ft xFrontRim=xRimCtr-dRim/2; // x location of front of rim from launch point of ball, ft xBackRim=xRimCtr+dRim/2; // x location of rear of rim from launch point of ball, ft yFrontRim=yRimCtr; // y location of front of rim above floor, ft yBackRim=yRimCtr; // y location of rear of rim above floor, ft // create a text box for user to input height of release point of ball tb1 = New Window("Input Parameters", <=yRimCtr+dBall/2, ( finalT=(vy0+sqrt(vy0^2-2*g*(yRimCtr-y0)))/g; // time that ball center reaches rim height, on the way down finalY=yRimCtr; // ball center height when at rim height, on the way down. finalX=vx0*finalT; // ball x position when center is at rim height, on the way down. finalVx=vx0; // ball final x velocity when center is at rim height, on the way down. finalVy=vy0-g*finalT; // ball final y velocity when center is at rim height, on the way down. thetaFinal=atan(finalVy,finalVx); // final trajectory angle when ball center is at rim height, on the way down, radians. angleFinal=thetaFinal*180/pi(); // final trajectory angle when ball center is at rim height, on the way down, degrees. // now we have all the information needed to determine if ball "swishes" through the rim opening // determine eqn of line through front of rim at finalTheta m=tan(thetaFinal); // slope of either line passing through front or rear of rim bFront=yFrontRim-m*xFrontRim; // intercept of line passing through front of rim at ball trajectory slope bBack=yBackRim-m*xBackRim; // intercept of line passing through back of rim at ball trajectory slope d=abs(bBack-bFront)/sqrt(m^2+1); // shortest distance between 2 parallel lines (ball must fit between these lines) // assume shot is made unless criteria is not met makemiss=1; // Criteria: If any are false, makemiss=0, else makemiss=1. // 1. Ball must be smaller than d (else it won't fit between front & back of rim without hitting) // 2. Ball center must be to right of front rim line (else falls short) // 3. Ball center must be to left of back rim line (else too long) // 4. Minimum distance from front rim line to ball must be >= dBall/2 // 5. Minimum distance from back rim line to ball must be >= dBall/2 if( dBall>d | finalXxBackRim | abs(-m*finalX+finalY-bFront)/sqrt(m^2+1^2)