#include #include #include #include using namespace std; #define pi 3.14159265359 int minfigx, : Notes">

NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

// Template project.
#include "graphics.h"//biblioteca ce contine primitivele si functiile grafice
#include <math.h>
#include <stdlib.h>
#include <dos.h>
#include <windows.h>
#include <iostream>

using namespace std;

#define pi 3.14159265359
int minfigx, maxx, maxy, minfigy, maxfigx, maxfigy;
float al = pi / 8;
struct P3d {
float x;
float y;
float z;
P3d(float x = 0, float y = 0, float z = 0) {
this->x = x;
this->y = y;
this->z = z;
}
};
P3d piramida[5];
void init()
{
initwindow(1200, 800);
maxx = getmaxx();
maxy = getmaxy();
minfigx = (int)(-maxx / 2);
maxfigx = (int)(maxx / 2);
minfigy = (int)(-maxy / 2);
maxfigy = (int)(maxy / 2);
piramida[0] = P3d(50, 50, 0);
piramida[1] = P3d(250, 50, 0);
piramida[2] = P3d(250, 250, 0);
piramida[3] = P3d(50, 250, 0);
piramida[4] = P3d(150, 150, 250);
}
int xe(float x)
{
return ((int)(floor)(((x - minfigx) / (maxfigx - minfigx))*maxx));
}
int ye(float y)
{
return ((int)(floor)(((maxfigy - y) / (maxfigy - minfigy))*maxy));
}
void axe()
{
//putpixel(xe(10), ye(10), RED);
line(xe(0), ye(0), xe(maxfigx), ye(0));
line(xe(0), ye(0), xe(0), ye(maxfigy));
line(xe(0), ye(0), xe(minfigx*cos(al)), ye(minfigx*sin(al)));
}
struct P2d {
float x;
float y;
P2d(float x = 0, float y = 0) {
this->x = x;
this->y = y;
}
};

P2d transformare3d2d(P3d Punct)
{
float xdeafisat;
float ydeafisat;
xdeafisat = (Punct.x - Punct.y*cos(al));
ydeafisat = (Punct.z - Punct.y*sin(al));
P2d nou=P2d();
nou.x = xdeafisat;
nou.y = ydeafisat;
return nou;
}
void desenarepiramida()
{
P2d piramida2d[5];
for (int i = 0;i < 5;i++)
piramida2d[i] = transformare3d2d(piramida[i]);
line(xe(piramida2d[0].x), ye(piramida2d[0].y), xe(piramida2d[1].x), ye(piramida2d[1].y));
line(xe(piramida2d[0].x), ye(piramida2d[0].y), xe(piramida2d[3].x), ye(piramida2d[3].y));
line(xe(piramida2d[2].x), ye(piramida2d[2].y), xe(piramida2d[3].x), ye(piramida2d[3].y));
line(xe(piramida2d[1].x), ye(piramida2d[1].y), xe(piramida2d[2].x), ye(piramida2d[2].y));
line(xe(piramida2d[0].x), ye(piramida2d[0].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
line(xe(piramida2d[1].x), ye(piramida2d[1].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
line(xe(piramida2d[2].x), ye(piramida2d[2].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
line(xe(piramida2d[3].x), ye(piramida2d[3].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
}
void translatiep()
{
int t1 = -120, t2 = -120;
for(int i=0;i<5;i++)
{
line(xe(piramida2d[0].x), ye(piramida2d[0].y), xe(piramida2d[1].x), ye(piramida2d[1].y));
line(xe(piramida2d[0].x), ye(piramida2d[0].y), xe(piramida2d[3].x), ye(piramida2d[3].y));
line(xe(piramida2d[2].x), ye(piramida2d[2].y), xe(piramida2d[3].x), ye(piramida2d[3].y));
line(xe(piramida2d[1].x), ye(piramida2d[1].y), xe(piramida2d[2].x), ye(piramida2d[2].y));
line(xe(piramida2d[0].x), ye(piramida2d[0].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
line(xe(piramida2d[1].x), ye(piramida2d[1].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
line(xe(piramida2d[2].x), ye(piramida2d[2].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
line(xe(piramida2d[3].x), ye(piramida2d[3].y), xe(piramida2d[4].x), ye(piramida2d[4].y));
/*
void triangle(int t1, int t2, int t3)
{
line(xe(t1), ye(t1), xe(t2), ye(y2));
}
*/
void translatie()
{
int t1 = -120, t2 = -120;
line(xe(30 + t1), ye(20 + t2), xe(100 + t1), ye(30 + t2));
line(xe(100 + t1), ye(30 + t2), xe(70 + t1), ye(70 + t2));
line(xe(70 + t1), ye(70 + t2), xe(30 + t1), ye(20 + t2));
}
void scale()
{
int t1 = 4, t2 = 4;
line(xe(30 * t1), ye(20 * t2), xe(100 * t1), ye(30 * t2));
line(xe(100 * t1), ye(30 * t2), xe(70 * t1), ye(70 * t2));
line(xe(70 * t1), ye(70 * t2), xe(30 * t1), ye(20 * t2));
}
void rotatie()
{
float al = -6 * pi / 180;
float xa = 30, ya = 20, xb = 100, yb = 30, xc = 70, yc = 70;
for (int i = 0;i < 60;i++)
{
cleardevice();
axe();

line(xe(xa), ye(ya), xe(xb), ye(yb));
line(xe(xb), ye(yb), xe(xc), ye(yc));
line(xe(xc), ye(yc), xe(xa), ye(ya));

Sleep(100);

xa = xa*cos(al) - ya*sin(al);
ya = xa*sin(al) + ya*cos(al);
xb = xb*cos(al) - yb*sin(al);
yb = xb*sin(al) + yb*cos(al);
xc = xc*cos(al) - yc*sin(al);
yc = xc*sin(al) + yc*cos(al);
}
}

void main() {


/*int t1, t2, t3;
cout << "t1=";cin >> t1;
cout << "t2=";cin >> t2;
cout << "t3=";cin >> t3;
*/
/*int ax = 30, ay = 20, bx = 100, by = 30, cx = 70, cy = 70;
line(xe(30), ye(20), xe(100), ye(30));
line(xe(100), ye(30),xe(70), ye(70));
line(xe(70), ye(70), xe(30), ye(20));
init();
rotatie();*/
init();
axe();

desenarepiramida();
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.