From 6bed7f80ea8e67c388f1c52a60237e7ceb8c274e Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 17 Sep 2019 21:25:27 +0200 Subject: Extract indicators, drawing of geometric primitives --- geometry/box.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 geometry/box.py (limited to 'geometry/box.py') diff --git a/geometry/box.py b/geometry/box.py new file mode 100644 index 0000000..5538819 --- /dev/null +++ b/geometry/box.py @@ -0,0 +1,58 @@ +from OpenGL.GL import * + +class Box: + def __init__(self, x0, x1, y0, y1, z0, z1): + self.x0 = x0 + self.x1 = x1 + self.y0 = y0 + self.y1 = y1 + self.z0 = z0 + self.z1 = z1 + + def indicator(self): + return lambda x, y, z: x >= self.x0 and x <= self.x1 and y >= self.y0 and y <= self.y1 and z >= self.z0 and z <= self.z1 + + def draw(self): + glBegin(GL_POLYGON) + glNormal(-1,0,0) + glVertex(self.x0, self.y0, self.z0) + glVertex(self.x0, self.y1, self.z0) + glVertex(self.x0, self.y1, self.z1) + glVertex(self.x0, self.y0, self.z1) + glEnd() + glBegin(GL_POLYGON) + glNormal(1,0,0) + glVertex(self.x1, self.y0, self.z0) + glVertex(self.x1, self.y1, self.z0) + glVertex(self.x1, self.y1, self.z1) + glVertex(self.x1, self.y0, self.z1) + glEnd() + glBegin(GL_POLYGON) + glNormal(0,0,1) + glVertex(self.x0, self.y0, self.z1) + glVertex(self.x1, self.y0, self.z1) + glVertex(self.x1, self.y1, self.z1) + glVertex(self.x0, self.y1, self.z1) + glEnd() + glBegin(GL_POLYGON) + glNormal(0,0,-1) + glVertex(self.x0, self.y0, self.z0) + glVertex(self.x1, self.y0, self.z0) + glVertex(self.x1, self.y1, self.z0) + glVertex(self.x0, self.y1, self.z0) + glEnd() + glBegin(GL_POLYGON) + glNormal(0,-1,0) + glVertex(self.x0, self.y0, self.z0) + glVertex(self.x1, self.y0, self.z0) + glVertex(self.x1, self.y0, self.z1) + glVertex(self.x0, self.y0, self.z1) + glEnd() + glBegin(GL_POLYGON) + glNormal(0,1,0) + glVertex(self.x0,self.y1,self.z0) + glVertex(self.x1,self.y1,self.z0) + glVertex(self.x1,self.y1,self.z1) + glVertex(self.x0,self.y1,self.z1) + glEnd() + -- cgit v1.2.3