Ko‘rinmas sirtlarni tanlash, Robеrts, z-bufеr, tartiblash, Appеl, -varnok algoritmlari Ishdan maqsad



Download 91,52 Kb.
bet8/9
Sana30.12.2021
Hajmi91,52 Kb.
#94478
1   2   3   4   5   6   7   8   9
Bog'liq
Ko‘rinmas chiziqlar va sirtlarni olib tashlash

C++ tilida dasturi:

#include

#include

#include

#include

#include


typedef float vek3[4];

typedef float vek8[9];

typedef float mat38[9][4];

typedef float mat28[9][3];

typedef int mat28i[9][3];

double alpha = 3.1415/4;

double l_kabine = 1/2.;

double d = 100;

vek3 z1;

mat38 kk3;

mat38 kk4;

mat28 kk2;

mat28i kk2i;

int ii,ff;

float ffi;

void initkub3( mat38 &k)

{

k[1][1]=0; k[1][2]=0; k[1][3]=0;



k[2][1]=d; k[2][2]=0; k[2][3]=0;

k[3][1]=0; k[3][2]=d; k[3][3]=0;

k[4][1]=0; k[4][2]=0; k[4][3]=d;

k[5][1]=d; k[5][2]=d; k[5][3]=0;

k[6][1]=0; k[6][2]=d; k[6][3]=d;

k[7][1]=d; k[7][2]=0; k[7][3]=d;

k[8][1]=d; k[8][2]=d; k[8][3]=d;

}

void kabine(mat38 m3, mat28 &m2)



{

int i;


for ( i=1; i<=8; i++)

{

m2[i][1] = m3[i][1] + l_kabine * sin(alpha) * m3[i][3];



m2[i][2] = m3[i][2] + l_kabine * cos(alpha) * m3[i][3];

}

}



void realtoint(mat28 m2, mat28i &m2i)

{

int i,j;



for(j=1; j<=8;j++)

for(i=1; i<=2;i++)

m2i[j][i]=int(m2[j][i]);

}

void lineside(vek3 z,mat38 k3,mat28i k2i,int n1,int n2,int n3,int n4)



{

if (((((k3[n3][2]-k3[n1][2])*(k3[n2][3]-k3[n1][3]))-

((k3[n3][3]-k3[n1][3])*(k3[n2][2]-k3[n1][2])))*z[1]-

(((k3[n3][1]-k3[n1][1])*(k3[n2][3]-k3[n1][3]))-

((k3[n2][1]-k3[n1][1])*(k3[n3][3]-k3[n1][3])))*z[2]+

(((k3[n3][1]-k3[n1][1])*(k3[n2][2]-k3[n1][2]))-

((k3[n2][1]-k3[n1][1])*(k3[n3][2]-k3[n1][2])))*z[3])<0 )

{

setcolor(15);



line(k2i[n1][1],k2i[n1][2],k2i[n2][1],k2i[n2][2]);

line(k2i[n2][1],k2i[n2][2],k2i[n3][1],k2i[n3][2]);

line(k2i[n3][1],k2i[n3][2],k2i[n4][1],k2i[n4][2]);

line(k2i[n4][1],k2i[n4][2],k2i[n1][1],k2i[n1][2]);

}

}

int main()



{ float ffi;

int gd=0,gm;

initgraph(&gd,&gm,"c:\\borlandc\\bgi");
z1[1]=l_kabine*sin(alpha);

z1[2]=l_kabine*cos(alpha);

z1[3]=-1;

initkub3(kk3);

for(ff=0;ff<=360;ff++)

{

for(ii=1;ii<=8;ii++)



{cleardevice();

ffi=ff*3.14/180.;

kk4[ii][1]=kk3[ii][1]+200;

kk4[ii][2]=cos(ffi)*kk3[ii][2]-sin(ffi)*kk3[ii][3]+200;

kk4[ii][3]=sin(ffi)*kk3[ii][2]+cos(ffi)*kk3[ii][3]+200;

kabine(kk4,kk2);

realtoint(kk2,kk2i);

lineside(z1,kk4,kk2i,1,2,5,3);

lineside(z1,kk4,kk2i,1,3,6,4);

lineside(z1,kk4,kk2i,1,4,7,2);

lineside(z1,kk4,kk2i,7,8,5,2);

lineside(z1,kk4,kk2i,5,8,6,3);

lineside(z1,kk4,kk2i,6,8,7,4);

delay(10);

}} getch();

return 0;}




Download 91,52 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish