Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#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;
float teta = 3.1415 / 180;
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
}
void desPiramida() {
Pct2d piramida2d[5];
for (int i = 0; i < 5; i++) {
piramida2d[i] = transf(piramida[i]);
}
line(Xe(piramida2d[0].x), Ye(piramida2d[0].y), Xe(piramida2d[1].x), Ye(piramida2d[1].y));
line(Xe(piramida2d[1].x), Ye(piramida2d[1].y), Xe(piramida2d[2].x), Ye(piramida2d[2].y));
line(Xe(piramida2d[2].x), Ye(piramida2d[2].y), Xe(piramida2d[3].x), Ye(piramida2d[3].y));
line(Xe(piramida2d[3].x), Ye(piramida2d[3].y), Xe(piramida2d[0].x), Ye(piramida2d[0].y));
line(Xe(piramida2d[4].x), Ye(piramida2d[4].y), Xe(piramida2d[0].x), Ye(piramida2d[0].y));
line(Xe(piramida2d[4].x), Ye(piramida2d[4].y), Xe(piramida2d[1].x), Ye(piramida2d[1].y));
line(Xe(piramida2d[4].x), Ye(piramida2d[4].y), Xe(piramida2d[2].x), Ye(piramida2d[2].y));
line(Xe(piramida2d[4].x), Ye(piramida2d[4].y), Xe(piramida2d[3].x), Ye(piramida2d[3].y));
}
void transPiramida() {
int tx = 60, ty = 60, tz = 60;
for (int i = 0; i < 5; i++) {
piramida[i].x = piramida[i].x + tx;
piramida[i].y = piramida[i].y + ty;
piramida[i].z = piramida[i].z + tz;
}
setcolor(LIGHTBLUE);
desPiramida();
}
void scalPiramidaplus() {
float sx = 1.5, sy = 1.5, sz = 1.5;
for (int i = 0; i < 5; i++) {
piramida[i].x = piramida[i].x * sx;
piramida[i].y = piramida[i].y * sy;
piramida[i].z = piramida[i].z * sz;
}
setcolor(LIGHTRED);
desPiramida();
}
void scalPiramidaminus() {
float sx = 0.25, sy = 0.25, sz = 0.25;
for (int i = 0; i < 5; i++) {
piramida[i].x = piramida[i].x * sx;
piramida[i].y = piramida[i].y * sy;
piramida[i].z = piramida[i].z * sz;
}
setcolor(LIGHTGREEN);
desPiramida();
}
void piramidarotireOX() {
for (int step = 0;step < 360;step++) {
for (int i = 0;i < 5;i++) {
piramida[i].x = piramida[i].x;
piramida[i].y = piramida[i].y*cos(teta) - piramida[i].z*sin(teta);
piramida[i].z = piramida[i].y*sin(teta) + piramida[i].z*cos(teta);
cleardevice();
axe3D();
desPiramida();
delay(10);
}
}
}
void piramidarotireOY() {
for (int step = 0;step < 360;step++) {
for (int i = 0;i < 5;i++) {
piramida[i].x = piramida[i].x*cos(teta) - piramida[i].y*sin(teta);
piramida[i].y = piramida[i].x*sin(teta) + piramida[i].y*cos(teta);
piramida[i].z = piramida[i].z;
cleardevice();
axe3D();
desPiramida();
delay(10);
}
}
}
void
void main() {
initwindow(1080, 720);
initializare();
Pct3d p3d;
p3d.x = 120;
p3d.y = 60;
p3d.z = 60;
Pct2d p2d = transf(p3d);
putpixel(Xe(p2d.x), Ye(p2d.y), LIGHTRED);
piramidarotireOY();
getch();
closegraph();
}
![]() |
Notes is a web-based application for online 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 14 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