求一个点绕原点旋转角度的程序

newarr 2008-10-08 10:15:39
如题.,给个点,求它绕原点转一定角度后的坐标.
...全文
273 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
langhua0001 2008-10-08
  • 打赏
  • 举报
回复
什么开发工具?
  • 打赏
  • 举报
回复
可以用,谢谢。
  • 打赏
  • 举报
回复
这个如何?
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef struct
{
double x;
double y;
}coordinate;

typedef struct
{
double r;
double angle;
}polar;

polar xy_to_polar(double x,double y)
{
polar poalr_cal;
poalr_cal.r=sqrt(pow(x,2)+pow(y,2));
poalr_cal.angle=atan2(y,x);
return poalr_cal;
}

coordinate polar_to_xy(double r,double angle)
{
coordinate cor_cal;
cor_cal.x=r*(cos(angle));
cor_cal.y=r*(sin(angle));
return cor_cal;
}
void main()
{
double angle_round;
coordinate cor1,cor2;
polar por;
cor1.x=1.0;
cor1.y=0.0;
angle_round=1.0; //取正代表逆时针转,取弧度值

por=xy_to_polar(cor1.x,cor1.y);
por.angle+=angle_round;
//printf("the polar is (%le,%le).\n",por.r,por.angle);
cor2=polar_to_xy(por.r,por.angle);
printf("The start point is (%lf,%lf).\n",cor1.x,cor1.y);
printf("After round %lf angle,the point is (%lf,%lf).\n",angle_round,cor2.x,cor2.y);
}

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧