The area(抛物线与直线的相交面积)
2013-09-09 21:11
309 查看
The area
时间限制(普通/Java):3000MS/10000MS 运行内存限制:65536KByte描述
Ignatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now given all the intersectant points shows in the picture, can you tell Ignatius the area of the land?
Note: The point P1 in the picture is a random point on the parabola, and P2, P3 are the intersectant points. Any two points of P1, P2 and P3 are not coincidence each other.
![](http://images.cnitblog.com/blog/566120/201309/09210454-27532df48fd0440da198b4d3b66318f5.bmp)
输入
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains three intersectant points which shows in the picture, they are given in the order of P1, P2, P3. Each point is described by two floating-point numbers X and Y(0.0<=X,Y<=1000.0).
输出
For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.
样例输入
2
5.000000 5.000000
0.000000 0.000000
10.000000 0.000000
10.000000 10.000000
1.000000 1.000000
14.000000 8.222222
样例输出
33.33
40.69
题目大意:给出抛物线顶掉p1的坐标及与直线的交点p2和p3的坐标,求相交部分的面积。
题解:抛物线面积:顶点为(x1,y1),方程为y=a(x-x1)^2+y1 ---->a=(y2-y1)/((x2-x1)*(x2-x1))
直线p2,p3的方程设为y=kx+b;-->k=(y3-y2)/(x3-x2);
又p2点在直线上,所以y2=k*x2+b,--->b=y2-k*x2;
然后微分,区间为(x2,x3),方程化简可得以下式子。
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int main() { int t; double x1,y1,x2,y2,x3,y3; cin>>t; while(t--) { scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3); double a=(y2-y1)/((x2-x1)*(x2-x1)); double k=(y3-y2)/(x3-x2); double b=y2-k*x2; double c=x3-x2; double d=x3*x3-x2*x2; double ans; ans=a*(x3*x3*x3-x2*x2*x2)/3-a*x1*d+a*x1*x1*c+y1*c-k*d/2-b*c; printf("%.2lf\n",ans); } return 0; }
相关文章推荐
- 求抛物线与直线相交面积
- 求抛物线直线相交面积题(Problem ID:1071)
- zju1010判断直线相交,求多边形面积
- ACM--抛物线和直线围成的面积–-HDOJ 1071--The area--水
- hdu1071(积分求直线和抛物线构成的面积)
- HDU 1071 The area(抛物线与直线围成的面积)
- POJ 1408 Fishnet (判断围成四边形最大面积,直线相交问题)
- 求抛物线与直线形成的面积(数学)
- HDU 1071 The area && 抛物线与直线积分面积
- YT14-HDU-求抛物线与直线间的面积(积分)
- hdu 1798 - Tell me the area(求两圆相交面积) 解题报告
- HDU-不定积分-求一条直线与抛物线所围成的面积
- POJ 1269 判断直线与直线相交
- 已知半径和两圆相交面积求圆心距
- BZOJ1007 水平相交直线
- 模版--两圆相交部分面积
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
- hdu 3264(二分+圆相交面积)
- HDU 5128 The E-pang Palace 几何题 求两个不相交矩阵面积和
- Tell me the area(计算几何--求两圆相交面积)