File: glPoint.py

package info (click to toggle)
pyopengl 2.0.1.09.dfsg.1-0.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 16,068 kB
  • ctags: 9,218
  • sloc: pascal: 66,059; xml: 28,092; python: 21,715; ansic: 20,706; tcl: 668; makefile: 247
file content (32 lines) | stat: -rw-r--r-- 827 bytes parent folder | download
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
import glVector

class glPoint (list):
	def __init__ (self, first = 0, second = 0, third = 0):
		# Allow creation from a vector
		if (isinstance (first, glVector.glVector)):
			self.x = first.i
			self.y = first.j
			self.z = first.k
		else:
			self.x = first
			self.y = second
			self.z = third

	def __str__ (self):
		return "x=%f y=%f z=%f" % (self.x, self.y, self.z)

	def __iadd__ (self, other):
		self.x += other.x
		self.y += other.y
		self.z += other.z
		return self

	def __add__ (self, other):
		result = glPoint (self.x, self.y, self.z)
		result += other
		return result

	def __sub__ (self, other):
		""" Create a vector from the difference between this point and another point """
		result = glVector.glVector (self.x - other.x, self.y - other.y, self.z - other.z)
		return result