A standard sphere ball is falling in the air, and the center of the sphere is exactly on the centerline of an empty isosceles trapezoidal. The trapezoid is hanging horizontally under the sphere.
Please determine whether the ball will get stuck in the trapezoid or drop past the trapezoid.
思路:高中数学题,补成三角形,用相似三角形做。
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
double r,a,b,h;
cin>>r>>a>>b>>h;
double h1;//b中点到三角形顶点的距离
h1=(b/(a-b))*h;
double H;//等腰三角形的高
H=(a/(a-b))*h;
double l;//小等腰三角形的斜边
l=H*r/(a/2);
double h0=sqrt(r*r+l*l);//球被卡住时圆心距离三角形顶点的距离
if(h0<=h1){
cout<<"Drop"<<endl;
}
else{
cout<<"Stuck"<<endl;
printf("%.10lf\n",h0-h1);
}
return 0;
}