1. 時針旋轉N度後的坐標問題 c語言
三個思路:
1.坐標變換,極坐標到直角坐標
2解方程,直線和圓相交
3三角函數
2. C語言實現經緯度的轉換
辦法很多,三維字元數組,指針字元數組都可以,分別保存字元串到數組元素,最後以%s輸出即可。
我來寫個最簡單的
#include "stdafx.h"
#include "stdlib.h"
#include "string.h"
void explain_NS(char * str)
{
char tmp_ca[30] = "";
if(str[0] == 'N')
strcpy(tmp_ca,"北緯");
else
strcpy(tmp_ca,"南緯");
char *p = tmp_ca;
while(*p) p++;
strncpy(p, str+1, 2);
p += 2;
*p = 176;
p ++;
strncpy(p,str+3,2);
p += 2;
*p = 39;
p++;
strncpy(p, str+6,5);
p += 5;
*p = 34;
printf("%s\n",tmp_ca);
}
void explain_EW(char * str)
{
char tmp_ca[30] = "";
if(str[0] == 'E')
strcpy(tmp_ca,"東經");
else
strcpy(tmp_ca,"西經");
char *p = tmp_ca;
while(*p) p++;
strncpy(p, str+1, 3);
p += 3;
*p = 176;
p ++;
strncpy(p,str+4,2);
p += 2;
*p = 39;
p++;
strncpy(p, str+7,5);
p += 5;
*p = 34;
printf("%s\n",tmp_ca);
}
int _tmain(int argc, _TCHAR* argv[])
{
char ca[30] = "N3018.93661";
char cb[30] = "E12022.88281";
explain_NS(ca);
explain_EW(cb);
system("pause");
return 0;
}
3. c語言程序 編寫一個函數f,將船如此函數的直角坐標值轉換為極坐標值,並返回主調函數中。急求,多謝!
給你幾個函數參考一下,詳細可以看它們的幫助文檔:其中sph為球坐標cart為笛卡爾pol為極坐標
4. 直角坐標轉極坐標c語言
#include <math.h>
double x,y,r,a;
scanf("%f%f",&x,&y);
r=sqrt(x*x,y*y);
a=atan2(x,y);
printf("r=%f,a=%f\n",r,a);