-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
78 lines (69 loc) · 1.66 KB
/
main.c
File metadata and controls
78 lines (69 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "graphmath.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifndef __WIN32
#define __USE_XOPEN /* required for useconds_t */
#include <unistd.h>
int usleep(useconds_t usec);
#define CROSS_SLEEP(ms) usleep(ms * 1000)
#define CLEAR_CONSOLE() system("clear")
#else
#include <windows.h>
#define CROSS_SLEEP(ms) Sleep(ms)
#define CLEAR_CONSOLE() system("cls")
#endif
int main(void){
const size_t s_points = 8;
const float cl = 5.0f;
vec3 points[8] = {
(vec3){cl, cl, cl},//CUBE
(vec3){cl, -cl, cl},
(vec3){cl, -cl, -cl},
(vec3){cl, cl, -cl},
(vec3){-cl, cl, cl},
(vec3){-cl, -cl, cl},
(vec3){-cl, -cl, -cl},
(vec3){-cl, cl, -cl},
/*(vec3){0.0f, cl, 0.0f},//TRIANGLE
(vec3){0.0f, -cl, -cl},
(vec3){0.0f, -cl, cl},*/
/*(vec3){cl, cl, 0.0f},//TETRAHEDRON
(vec3){cl, -cl, -cl},
(vec3){cl, -cl, cl},
(vec3){-cl, 0.0f, 0.0f},*/
};
vec3 theta = (vec3){0.0f, 0.0f, 0.0f};
vec2 v2;
vec3 v3;
char c;
const int width = 20*2;
const int height = 20*2;
while(1){
for(int y = height/2; y >= -height/2; --y){
for(int x = -width/2; x <= width/2; ++x){
c = ' ';
for(size_t i = 0; i < s_points; ++i){
v3 = rotate(points[i], theta);
v2 = point_projection(v3);
if(
lroundf(v2.x) == x &&
lroundf(v2.y) == y
) c = '#';
}
putchar(c);
}
putchar('\n');
}
// while(getchar() != '\n');
CROSS_SLEEP(40);
CLEAR_CONSOLE();
theta.z += 3.1415926535f / 24.0f;
theta.y += 3.1415926535f / 24.0f;
theta.x += 3.1415926535f / 24.0f;
if(theta.z >= 3.1415926535f * 2.0f) theta.z = 0.0f;
if(theta.y >= 3.1415926535f * 2.0f) theta.y = 0.0f;
if(theta.x >= 3.1415926535f * 2.0f) theta.x = 0.0f;
}
return 0;
}