-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtriangleminmax.h
More file actions
64 lines (54 loc) · 1.51 KB
/
Copy pathtriangleminmax.h
File metadata and controls
64 lines (54 loc) · 1.51 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
#pragma once
#include "screencoordinate.h"
struct TriangleMinMax
{
float minX, minY, maxX, maxY;
TriangleMinMax(const TriangleScreenCoordinates& triangleScreenCoordinates)
{
computeMinX(triangleScreenCoordinates.v1, triangleScreenCoordinates.v2, triangleScreenCoordinates.v3);
computeMinY(triangleScreenCoordinates.v1, triangleScreenCoordinates.v2, triangleScreenCoordinates.v3);
computeMaxX(triangleScreenCoordinates.v1, triangleScreenCoordinates.v2, triangleScreenCoordinates.v3);
computeMaxY(triangleScreenCoordinates.v1, triangleScreenCoordinates.v2, triangleScreenCoordinates.v3);
}
float getMinX() const
{
return minX;
}
float getMinY() const
{
return minY;
}
float getMaxX() const
{
return maxX;
}
float getMaxY() const
{
return maxY;
}
private:
void computeMinX(const ScreenCoordinate& v1, const ScreenCoordinate& v2, const ScreenCoordinate& v3)
{
minX = v1.x;
if (minX > v2.x) minX = v2.x;
if (minX > v3.x) minX = v3.x;
}
void computeMinY(const ScreenCoordinate& v1, const ScreenCoordinate& v2, const ScreenCoordinate& v3)
{
minY = v1.y;
if (minY > v2.y) minY = v2.y;
if (minY > v3.y) minY = v3.y;
}
void computeMaxX(const ScreenCoordinate& v1, const ScreenCoordinate& v2, const ScreenCoordinate& v3)
{
maxX = v1.x;
if (maxX < v2.x) maxX = v2.x;
if (maxX < v3.x) maxX = v3.x;
}
void computeMaxY(const ScreenCoordinate& v1, const ScreenCoordinate& v2, const ScreenCoordinate& v3)
{
maxY = v1.y;
if (maxY < v2.y) maxY = v2.y;
if (maxY < v3.y) maxY = v3.y;
}
};