Coverage for tatlin/lib/gl/boundingbox.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-03-20 05:56 +0000

1# -*- coding: utf-8 -*- 

2# Copyright (C) 2011 Denis Kobozev 

3# 

4# This program is free software; you can redistribute it and/or modify 

5# it under the terms of the GNU General Public License as published by 

6# the Free Software Foundation; either version 2 of the License, or 

7# (at your option) any later version. 

8# 

9# This program is distributed in the hope that it will be useful, 

10# but WITHOUT ANY WARRANTY; without even the implied warranty of 

11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12# GNU General Public License for more details. 

13# 

14# You should have received a copy of the GNU General Public License 

15# along with this program; if not, write to the Free Software Foundation, 

16# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 

17 

18 

19class BoundingBox(object): 

20 """ 

21 A rectangular box (cuboid) enclosing a 3D model, defined by lower and upper corners. 

22 """ 

23 

24 def __init__(self, upper_corner, lower_corner): 

25 self.upper_corner = upper_corner 

26 self.lower_corner = lower_corner 

27 

28 @property 

29 def width(self): 

30 width = abs(self.upper_corner[0] - self.lower_corner[0]) 

31 return round(width, 2) 

32 

33 @property 

34 def depth(self): 

35 depth = abs(self.upper_corner[1] - self.lower_corner[1]) 

36 return round(depth, 2) 

37 

38 @property 

39 def height(self): 

40 height = abs(self.upper_corner[2] - self.lower_corner[2]) 

41 return round(height, 2)