zoukankan      html  css  js  c++  java
  • hud1700(计算几何——求等边三角形)

    题意:圆心在原点,一个坐标(x,y)在圆上,通过这个点画一个三角形在圆内,三角形其顶点都在圆上,要求三角形的周长最大,输出满足这样条件的三角形的另两个坐标.....

    思路:有一个公式是把一个向量平移多少角度的......a向量=(x,y),要将a向量旋转120度

    x1=x*cos(120.0/180.0*PI)-y*sin(120.0/180.0*PI);
    y1=y*cos(120.0/180.0*PI)+x*sin(120.0/180.0*PI);

    平移过后就变成了(x1,y1)......

    公式:(x*cosθ- y * sinθ, y*cosθ + x * sinθ)

    需要注意的是,是向量平移,而不是坐标旋转.........

    #include<iostream>
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    using namespace std;
    #define PI 3.1415926535
    //(x*cosθ- y * sinθ, y*cosθ + x * sinθ)
    int main()
    {
    	int text;
    	scanf("%d",&text);
    	while(text--)
    	{
    		double x,y,x1,y1;
    		scanf("%lf%lf",&x,&y);
    		x1=x*cos(120.0/180.0*PI)-y*sin(120.0/180.0*PI);
    		y1=y*cos(120.0/180.0*PI)+x*sin(120.0/180.0*PI);
    		//double x1=x,y1=y;
    		x=x1*cos(120.0/180.0*PI)-y1*sin(120.0/180.0*PI);
    		y=y1*cos(120.0/180.0*PI)+x1*sin(120.0/180.0*PI);
    		if(fabs(y1-y)<0.0005)
    		{
    			if(x<x1)
    			printf("%.3lf %.3lf %.3lf %.3lf
    ",x,y,x1,y1);
    			else
    			printf("%.3lf %.3lf %.3lf %.3lf
    ",x1,y1,x,y);
    		}
    		else if(y<y1)
    		printf("%.3lf %.3lf %.3lf %.3lf
    ",x,y,x1,y1);
    		else
    		printf("%.3lf %.3lf %.3lf %.3lf
    ",x1,y1,x,y);
    	}
    	return 0;
    }
    
  • 相关阅读:
    nginx内置高可用配置与第三方高可用模块nginx_ustream_check_mudule配置
    nginx+php,nginx+tomcat动静分离实战
    面向对象三大特性之多态与多态性
    面向对象三大特性之组合
    面向对象三大特性之继承与派生
    面向对象编程初探
    常用模块
    模块
    函数
    文件处理
  • 原文地址:https://www.cnblogs.com/ziyi--caolu/p/3258422.html
Copyright © 2011-2022 走看看