Ⅰ 平面直角坐標向經緯度坐標轉換公式,我要用c語言寫程序,急需~~
什麼意思?說清楚???
Ⅱ 怎樣用C語言實現天球坐標系與直角坐標系之間的轉換,用編程實現。求大神指導,非常感謝
#include <stdio.h>
#include <math.h>
int main()
{
//輸入格式:α,β,r β是縱軸的夾角
double angle_a,angle_b;
double radin;
double x,y,z;
scanf("%lf%lf%lf",&angle_a,&angle_b,&radin);
x = radin*cos(angle_a);
y = radin*sin(angle_a);
z = radin*cos(angle_b);
printf("%lf\t%lf\t%lf\t",x,y,z);
return 0;
}
Ⅲ 用C語言或者C++實現大地坐標系與大地空間直角坐標系的轉換
當球心在z=1點時,r和上面的不一樣。此時r^2=R^2+2rcos(PHI)-1r^2-2rcos(PHI)=R^2-1[r-cos(PHI)]^2=R^2-1+[cos(PHI)]^2然後開根號 得到r與R和PHI的關系式。因為r是表示球面上的點到坐標原點的距離,所以當球心改變時,距離表達式一定不一樣。
Ⅳ c語言編出的圖形如直線是以左上角為(0,0)點如何調整成符合習慣的坐標系
c語言本身是無法調整的,但是如果為了使用原點為左下角的坐標系完全可以用坐標變
換實現,你只需要自己寫一個自己的直線函數,即參數為以左下角為原點的直線的端點
的直線函數。並在函數中作一次坐標變換就可以了,舉個例子:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
/*直線函數*/
void myline(int x1, int y1, int x2, int y2)
{
int ymax = getmaxy(); /*獲得屏幕最低點的y坐標*/
y1 = ymax - y1; /*坐標變換*/
y2 = ymax - y2;
line(x1, y1, x2, y2);
}
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "h:\\work\\tc3\\bgi");
/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
setcolor(getmaxcolor());
xmax = getmaxx();
ymax = getmaxy();
/* 這是原來的直線函數*/
line(0, 0, xmax, ymax);
/* 這是變換後的直線函數*/
myline(0,0,xmax,ymax);
/* clean up */
getch();
closegraph();
return 0;
}
不過不推薦使用這種方法,其實,坐標原點在哪裡都是一樣的,用習慣就好了。
Ⅳ 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;
}
Ⅵ C語言畫圖模式下如何將當前坐標賦給一個變數方面下面引用該坐標值。
樓主您好,你這個分值已經吸引了我
在下不才,也是自己寫過一些c語言畫圖模式下的程序。所以我認為我在這一方面具有一定的權威.
(文本模式下)
我對於您的問題理解的不是很透徹,但是看字面意思來說,您是想當前坐標賦值給變數,我假設變數為(x、y)分別為x軸、y軸坐標變數。則將坐標賦值,為x=getx();y=gety();
(畫圖模式下)
在這里,我一般是直接對寄存器進行中斷取得 滑鼠 的值。在對他進行操作。
c語言只有以上2種模式,通過你的提問,我覺得你問的是文本模式下的。如果你覺得我回答不夠詳細,可以直接加QQ:942690451 詢問。
Ⅶ 求一段C語言圖形旋轉就是整體坐標的轉換的代碼
原來的三點
line(25,50,50,50);
line(50,50,50,25);
line(50,25,25,50);
是個三角形
我想旋轉一點的角度,該如何改寫
如輸入angle:30