c语言给定n个点的坐标,C语言编写程序计算圆上的点的坐标

Problem Description

There is a cycle with its center on the origin.

Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other

you may assume that the radius of the cycle will not exceed 1000.

Input

There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.

Output

For each testcase you are supposed to output the coordinates of both of the unknow points by 3 decimal places of precision

Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X.

NOTE

when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.

Sample Input

2

1.500 2.000

563.585 1.251

Sample Output

0.982 -2.299 -2.482 0.299

-280.709 -488.704 -282.876 487.453

译:

问题描述:

有一个以原点为中心的圆

现在给你一个圆上的点,要求你找到圆上的另外的两个点,保证这三个点彼此之间的距离最大

你可以假设圆的半径不超过1000

输入:

有T个测试数据,每个测试数据要求输入两个十进制数代表给定点的坐标

输出

对于每个测试用例,您应该输出两个未知点的坐标,精确到小数点后3位

总是先输出较低的值(Y坐标值较小),如果它们的Y值与较小X值的值相同的话。

请注意

当输出时,如果X1和X2的绝对值小于0.0005,我们假设它们相等。

样例输入

2

1.500 - 2.000

563.585 - 1.251

样例输出

0.982 -2.299 -2.482 0.299

-280.709 -488.704 -282.876 487.453

思路:圆内接正三角形时,3个点彼此之间距离最大,可以先求角度(利用atan2可以由斜率得到角度),每次旋转120,用极坐标的方式再求直角坐标。

#include

#include

#define PI 3.1415926

int main() {

double x, y, r, a;

int n;

scanf("%d", &n);

for (int i = 0; i < n; i++) {

scanf("%lf%lf", &x, &y);

r = sqrt(x*x + y * y);//求半径

a = atan2(y, x);//求角度

for (int i = 0; i < 2; i++) {

a -= PI * 2 / 3;//旋转120度

printf("%0.3lf %0.3lf", r * cos(a), r * sin(a));

if (i == 0)

printf(" ");

}

printf("\n");

}

return 0;

}

已知圆上三个点坐标,求圆半径 r 和 圆心坐标

问题: 已知圆上三个点坐标分别为(x1,y1).(x2,y2).(x3,y3) 求圆半径R和圆心坐标(X,Y) X,Y,R为未知数,x1,y1,x2,y2,x3,y3为常数 则由圆公式:(x1-X)² ...

JS Math&period;sin&lpar;&rpar; 与 Math&period;cos&lpar;&rpar; 用法 &lpar;含圆上每个点的坐标&rpar;

Math.sin(x)      x 的正玄值.返回值在 -1.0 到 1.0 之间: Math.cos(x)    x 的余弦值.返回的是 -1.0 到 1.0 之间的数: 这两个函数中的X 都是指 ...

C语言编写程序的大小端问题

有时候,用C语言写程序需要知道大端模式还是小端模式,,由于寄存器大于一个字节(8bit),就会存在一个字节安排的问题,例如(16bit)的short型,(32bit)的int型,具体需要看具体的编译器 ...

【POJ 1981】Circle and Points&lpar;已知圆上两点求圆心坐标&rpar;

[题目链接]:http://poj.org/problem?id=1981 [题意] 给你n个点(n<=300); 然后给你一个半径R: 让你在平面上找一个半径为R的圆; 这里R=1 使得这个圆 ...

cp/tar/用c语言编写程序 实现cp命令的效果

1.cp (拷贝) 已存在文件路径  要拷贝的文件路径 实现cp命令的代码如下: #include //因为要在命令中得到两个路径,所以要用到main函数的两个参数 i ...

python根据圆的参数方程求圆上任意一点的坐标

from math import cos, sin,pi x0,y0=0,0 r=4.0 angle=-25 x1 = x0 + r * cos(angle * pi / 180) y1 = y0 + ...

C语言编写的bmp读写程序

C语言编写的bmp读写程序 建议先把bmp的数据存储格式了解下 #include "Windows ...

Linux平台上常用到的c语言开发程序

Linux操作系统上大部分应用程序都是基于C语言开发的.小编将简单介绍Linux平台上常用的C语言开发程序. 一.C程序的结构1.函数 必须有一个且只能有一个主函数main(),主函数的名为main. ...

&lbrack;转载&rsqb; 使用C&sol;C&plus;&plus;语言编写基于DSP程序的注意事项

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值