http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2432

题目大意:

如图,定义三角形ABC,在BC,CA,AB上分别取边D,E,F,使得CD=2BD,AE=2CE,BF=2AF,求三角形PQR的面积。

思路:

先求出D,E,F三点坐标,然后求出PQR三点坐标,最后对pr,pq进行叉乘,所得的一般即为答案。

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=300+10; struct Point
{
double x, y;
Point(double x=0, double y=0):x(x),y(y) { } };
typedef Point Vector;
Vector operator + (const Vector& A, const Vector& B) { return Vector(A.x+B.x, A.y+B.y); }
Vector operator - (const Point& A, const Point& B) { return Vector(A.x-B.x, A.y-B.y); }
Vector operator * (const Vector& A, double p) { return Vector(A.x*p, A.y*p); }
Vector operator / (const Vector& A, double p) { return Vector(A.x/p, A.y/p); } double Cross(const Vector& A, const Vector& B) { return A.x*B.y - A.y*B.x; } //两直线交点,参数式。
Point GetLineIntersection(const Point& P, const Vector& v, const Point& Q, const Vector& w) {
Vector u = P-Q;
double t = Cross(w, u) / Cross(v, w);
return P+v*t;
} Point a,b,c;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
Vector BD=(c-b)/3;
Vector AF=(b-a)/3;
Vector CE=(a-c)/3;
Point d=b+BD;
Point f=a+AF;
Point e=c+CE;
Point p=GetLineIntersection(d,a-d,b,b-e);
Point q=GetLineIntersection(c,c-f,b,b-e);
Point r=GetLineIntersection(c,c-f,d,a-d);
printf("%.0lf\n",Cross(p-q,p-r)/2);
}
return 0;
}

UVA 11437 - Triangle Fun 向量几何的更多相关文章

  1. UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)

    Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...

  2. 简单几何(求交点) UVA 11437 Triangle Fun

    题目传送门 题意:三角形三等分点连线组成的三角形面积 分析:入门题,先求三等分点,再求交点,最后求面积.还可以用梅涅劳斯定理来做 /********************************** ...

  3. uva 11437 - Triangle Fun

    计算几何: 直线交点: #include<cstdio> using namespace std; struct node { double x,y; node(,):x(x),y(y){ ...

  4. uva 11401 Triangle Counting

    // uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...

  5. UVa 11437 (梅涅劳斯定理) Triangle Fun

    题意: 给出三角形ABC顶点的坐标,DEF分别是三边的三等分点.求交点所形成的三角形PQR的面积. 分析: 根据梅涅劳斯定理,我们得到: ,解得 另外还有:,解得 所以AR : RP : PD = 3 ...

  6. UVA 11178 Morley's Theorem(几何)

    Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...

  7. UVA 11796 - Dog Distance 向量的应用

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  8. UVA 11646 - Athletics Track || UVA 11817 - Tunnelling the Earth 几何

    题目大意: 两题几何水题. 1.UVA 11646 - Athletics Track 如图,体育场的跑道一圈400米,其中弯道是两段半径相同的圆弧,已知矩形的长宽比例为a:b,求长和宽的具体数值. ...

  9. UVa 488 - Triangle Wave

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...

随机推荐

  1. from disk cache 与 from memory cache

    webkit资源的分类 webkit的资源分类主要分为两大类:主资源和派生资 http状态码 200 from memory cache 不访问服务器,直接读缓存,从内存中读取缓存.此时的数据时缓存到 ...

  2. 使用表单向action提交时出现 “Error setting expression 'button' with value……”

    原因是,form中的组件设置了name属性,struts2会通过OGNL在action中找相应的属性. 如 <form action="login"> <intp ...

  3. JSON初入门

    JSON:Javascript Object Notation 轻量级的数据交换格式 语法规则:(JSON语法是js对象表示语法的子集) 1.数据在名称/值对中 2.数据由逗号分隔 3.花括号{}保存 ...

  4. js---11运算符,流程控制,真假

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  5. php intval函数

    php intval函数 作用 intval — 获取变量的整数值 使用实例 <?php echo intval('-42'); // -42 ?> 相似函数 boolval() - 获取 ...

  6. Js将类数组转化为数组

    说起伪数组,大家可能会想到arguments, 这个我们函数参数的一个类数组,是类数组的代表. 1.拥有length属性,可以使用下标来访问元素,这两点和数组相同. 2.不能使用数组的方法,他们不能使 ...

  7. js对数组进行操作

    1.数组的创建 var arrayObj = new Array(); //创建一个数组 var arrayObj = new Array([size]); //创建一个数组并指定长度,注意不是上限, ...

  8. 你必须要知道的几个CSS技巧

    有些经典的CSS技巧,我们还是需要记住的,这样可以节省我们大量的时间,下面零度就为大家推荐几个比较好的CSS技巧: 1.在不同页面上使用同样的导航代码 许多网页上都有导航菜单,当进入某页时,菜单上相应 ...

  9. 关于SQL分页存储过程的分析

    建 立一个 Web 应用,分页浏览功能必不可少.这个问题是数据库处理中十分常见的问题.经典的数据分页方法是:ADO 纪录集分页法,也就是利用ADO自带的分页功能(利用游标)来实现分页.但这种分页方法仅 ...

  10. Fragment-Transaction 源码分析

    概述 这篇文章的简要分析了Activity中的Transaction和add,replace等操作以及backstack的工作原理. 分析transaction源码的原因是因为我在写一个测试代码的时候 ...