當前位置:首頁 » 編程語言 » c語言坐標函數
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言坐標函數

發布時間: 2023-03-21 13:06:49

c語言坐標函數用f嗎

c語言坐標函數可以用f
1.編寫程序,將直角坐標值轉化為極坐標。極坐標的指哪公式是:

c= sqrt(x*x+y*y), 唯輪碼q=arctan(y/x)

函數f的定義為:void fun(double x,double y,double *c,double *q),其中x, y為輸入的直角坐標,指針c, q用於返回計算得到的桐做極坐標值。

主程序讀入x, y,輸出c, q,其中c,q保留小數點後面兩位。

㈡ c語言 坐標

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;
initgraph(&gdriver, &gmode, ""); \*初試化圖形*/

errorcode = graphresult();

if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}

setcolor(getmaxcolor()); \*可以選擇顏色比如color(2)是一種顏色*/
xmax = getmaxx();
ymax = getmaxy();

line(0, 0, xmax, ymax);

getch();
closegraph();
return 0;
}
自己遠行一下看看就明白了

㈢ 菜鳥求教C語言acos函數和坐標

acos(
)
的形參當然有范圍,-1,至1,閉區間,基本的數學知識則神世,如果朝界控制台會顯示-1.#IND,表示數據超界;關於坐瞎粗標的函數當然有,需要用到結構體COORD,以及頭文件windows.h
具體代碼如下:
#include
<windows.h>
#include
<stdio.h>孫肢
void
gotoxy(int
x,int
y)
{
COORD
coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void
main()
{
gotoxy(50,60);
printf("I
LOVE
YOU");
}
這個程序就實現了移動游標到指定位置,然後輸出指定的內容。

㈣ C語言設計函數頂點坐標

參考代碼如下:

函磨洞數頭文件CalC.h

doublearround(doublex[],doubley[],intp);

函數定義文件CalC.c

#include<math.h>
doublearround(doublex[],doubley[],intp)
{
瞎段枯inti;
doubleC=0;//周長
doublel_p_i;//第i條邊長度
for(i=0;i<p;i++)
{
燃好l_p_i=sqrt((y[i+1]-y[i])*(y[i+1]-y[i])+(x[i+1]-x[i])*(x[i+1]-x[i]));
printf("第%d條邊長=%f ",i+1,l_p_i);
C+=l_p_i;
}

returnC;
}

主文件main.c

#include<stdio.h>
#include"CalC.h"

intmain(void)
{
doublex[3]={0.0,4.0,4.0};
doubley[3]={0.0,0.0,3.0};
intp=3;

doubleC=0.0;//周長
C=arround(x,y,p);
printf("C=%f ",C);

return0;
}

效果圖

㈤ 求用c語言實現直角坐標(x,y,z)轉換為球坐標(r,angle_a,angle_b),非常感謝

首先,matlab 本身提供了把直角坐標轉化為極坐標的函數cart2pol。調用方法為:

[TH,R] = cart2pol(X,Y) TH 是極坐標的角度坐標,R 是距離坐標。

[TH,R,Z] = cart2pol(X,Y,Z) 這個函數同時支持3維直角坐標到柱坐標的轉換。

如果因為是作業或者練習,一定要自己寫一個的話,請繼續往下看。

考慮到這個程序的性質,編成一個函數比較適合。編寫這個函數需要用到直角坐標與極坐標的數學關系。考慮到世鏈輸入參數可能是一個向量或矩陣如手,關系式裡面的搜橡孫運算符應該用加點運算符。

函數代碼如下:

function [ TH,R ] = mycart2pol(X,Y)

%this function transforms corresponding elements of data

%stored in Cartesian coordinates X,Y to polar coordinates

%angle TH and radius R.

R=(X.^2+Y.^2).^0.5;

TH=atan(Y./X);

end

測試結果如下:

㈥ 求高手們用C語言編寫一個函數,根據兩個變數自動顯示點的坐標(X,Y,Z)

//class是寫成類嗎,這個寫成類有點多此一舉,下面用最簡單的函數寫的,變數自己改成英文命名
1.h
#include<stdio.h>
#include<math.h>

//宏定義值
#definehXX
#defineLXX
#defineαXX

doubleβ,θ;
doubleA[3],B[3],M[3];
voidmath(β,θ,A,B,M);

1.cpp
#include"1.h"

math(β,θ,A,B,M)
{
A[0]=L*sin(fabs(θ-α));
A[1]=L*cos(fabs(θ-α))*cosβ;
A[2]=L*cos(fabs(θ-α))*sinβ,
//公式太長自己寫
}

voidmain()
{
printf("請輸入β,θ的值: ");
scanf("%f,%f",&β,&θ);
math(β,θ,A,B,M);
printf("A的坐標為:(%f,%f,%f) ",A[0],A[1],A[2]);
//輸出自己寫
}

㈦ c語言中若要輸入坐標應該怎麼辦

先算出縱坐標的值,然後
用二維數組來存儲坐標,如:int a[5][5]; 可以用a[0][0] a[0][1]....
a[i][j]....a[4][3] a[4][4],來存儲5對坐標值,i、j分別是橫坐標和縱坐標。

㈧ C語言里有沒有可以獲取特定顏色區域點的坐標的函數

c語言標准函數庫里肯定是沒有,c/c++界面開發工具QT,MFC估計會有

㈨ 用C語言編寫一個程序:定義一個點的坐標,然後定義兩個點,求這兩個點間的距離。

#include<stdio.h>
#include<math.h>

structPoint
{
doublex,y;
};

/**.*/
doubledistance(conststructPoint*a,conststructPoint*b)
{
returnsqrt((a->x-b->x)*(a->x-b->x)+(a->y-b->y)*(a->y-b->y));
}

intmain()
{
structPointa,b;
printf("Pleaseinputthefirstpoint:");
scanf("%lf%lf",&a.x,&a.y);
printf("Pleaseinputthesecondpoint:");
scanf("%lf%lf",&b.x,&b.y);
printf("Thedistanceofthetwopointis%f. ",distance(&a,&b));
return0;
}

說明:

1、distance() 函數的兩個參數 const struct Point *a 和 b 使用了 const 修飾,是表示 a 和 b 在函數執行過程中不會被修改;這樣即使函數體內部寫錯,修改了 a 和 b 的值,編譯也不會通過。

2、對 double,scanf 用 %lf,printf 用 %f。

以上。

㈩ 菜鳥求教C語言acos函數和坐標

acos( ) 的形參當然有范圍,-1,至1,閉區間,基本的數學知識,如果朝界控制台會顯示-1.#IND,表示數據超界;關於坐標的函數渣液當然有,需要用到結構體COORD,以慧友及頭文件windows.h 具體代碼如下:
#include <windows.h>
#include <stdio.h>
void gotoxy(int x,int y)
{
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void main()
{
gotoxy(50,60);
printf("I LOVE YOU");
}
這個程序就實現了移動游標到指前梁槐定位置,然後輸出指定的內容。