-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry.c
71 lines (54 loc) · 865 Bytes
/
geometry.c
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
#include <stdio.h>
#include <stdlib.h>
#include "geometry.h"
RECT rect(int x, int y, int size_x, int size_y)
{
RECT rectangle;
rectangle.x = x;
rectangle.y = y;
rectangle.size_x = size_x;
rectangle.size_y = size_y;
return rectangle;
}
POINT2 point2(int x, int y)
{
POINT2 point;
point.x = x;
point.y = y;
return point;
}
POINT3 point3(int x, int y, int z)
{
POINT3 point;
point.x = x;
point.y = y;
point.z = z;
return point;
}
VECTOR2 vector2(float x, float y)
{
VECTOR2 vector;
vector.x = x;
vector.y = y;
return vector;
}
VECTOR3 vector3(float x, float y, float z)
{
VECTOR3 vector;
vector.x = x;
vector.y = y;
vector.z = z;
return vector;
}
int inside_rect(int x, int y, RECT rect)
{
if( x >= rect.x && x < rect.x + rect.size_x &&
y >= rect.y && y < rect.y + rect.size_y)
{
return 1;
}
else
{
return 0;
}
}