C语言 指教坐标转换为极坐标
来源:互联网 发布:淘宝沙箱测试环境 编辑:程序博客网 时间:2024/06/02 03:22
C语言 指教坐标转换为极坐标
#include<stdio.h>#include<math.h>struct complex_s{ double x,y;};double real_part(struct complex_s z){ return z.x;}double img_part(struct complex_s z){ return z.y;}double magnitude(struct complex_s z){ return sqrt(z.x*z.x + z.y*z.y);}double angle(struct complex_s z){ return atan2(z.y, z.x);}struct complex_s make_from_real_img(double x, double y){ struct complex_s z; z.x = x; z.y = y; return z;}struct complex_s make_from_mag_ang(double r, double A){ struct complex_s z; z.x = r * cos(A); z.y = r * sin(A); return z;}struct complex_s add_complex(struct complex_s z1,struct complex_s z2){ return make_from_real_img(real_part(z1)+real_part(z2), img_part(z1) + img_part(z2));}struct complex_s sub_complex(struct complex_s z1,struct complex_s z2){ return make_from_real_img(real_part(z1)-real_part(z2), img_part(z1) - img_part(z2));}struct complex_s mul_complex(struct complex_s z1,struct complex_s z2){ return make_from_mag_ang(real_part(z1)*real_part(z2), img_part(z1) + img_part(z2));}struct complex_s div_complex(struct complex_s z1,struct complex_s z2){ return make_from_mag_ang(real_part(z1)/real_part(z2), img_part(z1) + img_part(z2));}int main(void){ struct complex_s z1 = {3.0,4.0}; struct complex_s z2= {2.0,5.0}; struct complex_s x; x = add_complex(z1,z2); printf("x={%f,%f}",x.x,x.y); return 0;}
结果:
[root@localhost struct]# ./jizuobiao.out x={5.000000,9.000000}
0 0
- C语言 指教坐标转换为极坐标
- C语言实现直角坐标转换为极坐标
- 极坐标转换为直角坐标
- opencv笛卡尔坐标转换为极坐标cvLogPolar的应用
- 经纬度坐标转换为屏幕坐标
- opengl 窗口坐标转换为物体坐标
- 经纬度坐标转换为屏幕坐标
- 经纬度坐标转换为屏幕坐标
- 经纬度坐标转换为屏幕坐标
- (转)经纬度坐标转换为屏幕坐标
- 【未完成】GPS坐标转换为平面坐标
- 经纬度坐标转换为屏幕坐标
- GPS坐标转换为百度地图坐标
- 将GPS坐标转换为火星坐标
- 客户端区域坐标转换为 Canvas 坐标
- C.5 坐标转换
- GPS坐标转换为百度坐标,百度坐标的转换,原始坐标转百度坐标
- 世界转换为节点坐标
- [Android实例] [版主原创]android之ScrollView里嵌套ListView
- 嵌入式 Linux 进程间通信之信号灯的几点注意事项
- form表单提交之前判断
- 漫画制作软件EasyComic V1.7发布
- Party All the Time+hdu+三分搜索
- C语言 指教坐标转换为极坐标
- 上海白玉兰妇科医院为你介绍骗子的骗术
- Eclipse <Unhandled event loop exception>
- Cocos2d-x 3.0开发(十三)使用CocoStudio编辑帧事件并关联到程序
- new balance qJNd eIf5 jfhN
- Python内建函数str()和repr()
- Objective-C 类
- 同一进程中同一端口如何区分不同的Socket
- 思维导图MindManager的文件格式与例图