#include #include #include #include using namespace std; int xMin, xMax, yMin, yMax, a, b; float alfa = 3.14 / 8; struct Pct2d { float x; float y; Pct2d(float x = 0, : Notes">

NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include "graphics.h"
#include <math.h>
#include <stdlib.h>
#include <dos.h>
#include <windows.h>
#include <iostream>

using namespace std;

int xMin, xMax, yMin, yMax, a, b;
float alfa = 3.14 / 8;


struct Pct2d {
float x;
float y;

Pct2d(float x = 0, float y = 0) {
this->x = x;
this->y = y;
}
};

struct Pct3d {
float x;
float y;
float z;

Pct3d(float x = 0, float y = 0, float z = 0) {
this->x = x;
this->y = y;
this->z = z;
}

};
Pct3d piramida[5];

Pct2d transf(Pct3d pct) {
float xPrim = (int)(pct.x - pct.y*cos(alfa));
float yPrim = (int)(pct.z - pct.y*sin(alfa));
Pct2d nou = Pct2d();
nou.x = xPrim;
nou.y = yPrim;

return nou;
}

void initializare() {

a = getmaxx();
b = getmaxy();
xMin = -a / 2;
xMax = a / 2;
yMin = -b / 2;
yMax = b / 2;

piramida[0] = Pct3d(50, 50, 0);
piramida[1] = Pct3d(250, 50, 0);
piramida[2] = Pct3d(250, 250, 0);
piramida[3] = Pct3d(50, 250, 0);
piramida[4] = Pct3d(150, 150, 250);
}

int Xe(float x) {

return (int)(floor)((x - xMin) / (xMax - xMin) *a);
}

int Ye(float y) {

return (int)(floor)((yMax - y) / (yMax - yMin)*b);
}

void axe3D() {
line(Xe(0), Ye(0), Xe(0), Ye(yMax)); //O-Y
line(Xe(0), Ye(0), Xe(xMax), Ye(0)); //O-X
line(Xe(0), Ye(0), Xe(0 + xMin*cos(alfa)), Ye(0 + xMin*sin(alfa))); //O-Z
}
Pct3d sp[3000];
Pct2d sp2d;
int n = 0;

void spirala() {
float x, y, z;
// setcolor(YELLOW);
float h = 3.1415 / 10;
float t = 0;
for (t = 0;t <= 100;t += h) {
x = t*cos(t / 4);
y = t*sin(t / 4);
z = t;
sp[n] = Pct3d(x, y, z);
n++;
}

for (int i = 0;i < n;i++) {
sp2d = transf(sp[i]);
putpixel(Xe(sp2d.x), Ye(sp2d.y), YELLOW);
}
}
void rotireSP() {
spirala();
float beta = -2 * 3.1415 / 180;
for (int j = 0;j < 360;j++) {
cleardevice();
axe3D();
for (int i = 0;i < n;i++) {
sp[i].x = sp[i].x*cos(beta) - sp[i].y*sin(beta);
sp[i].y = sp[i].x*sin(beta) + sp[i].y*cos(beta);
sp[i].z = sp[i].z;
sp2d = transf(sp[i]);
putpixel(Xe(sp2d.x), Ye(sp2d.y), YELLOW);
}

Sleep(25);
}
}

float distanta(Pct2d A, Pct2d B)
{
return sqrt((int)((B.x - A.x)*(B.x - A.x) + (B.y - A.y)*(B.y - A.y)));
}
void puncte()
{
Pct2d A, B;
cout << "introudecti coordonate pentru A" << endl;
cin >> A.x;
cin >> A.y;
cout << "introudecti coordonate pentru B" << endl;
cin >> B.x;
cin >> B.y;
cout << "Distanta dintre A si B este " << distanta(A, B);
line(Xe(A.x), Ye(A.x), Xe(B.x), Ye(B.y));

}


void main() {
initwindow(1080, 720);

initializare();
axe3D();

Pct3d p3d;
p3d.x = 120;
p3d.y = 60;
p3d.z = 60;
Pct2d p2d = transf(p3d);

putpixel(Xe(p2d.x), Ye(p2d.y), LIGHTRED);



puncte();

getch();
closegraph();

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.