Commit b668c996 authored by sumpfralle's avatar sumpfralle

r642@erker: lars | 2010-02-11 02:13:30 +0100

 fixed caching of "normal" (removed double function definition)
 unified caching of "plane"


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@107 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 2ece945d
...@@ -125,9 +125,9 @@ class Triangle: ...@@ -125,9 +125,9 @@ class Triangle:
def normal(self): def normal(self):
if self._normal is None: if self._normal is None:
# calculate normal, if p1-p2-pe are in clockwise order # calculate normal, if p1-p2-pe are in clockwise order
n = self.p3.sub(self.p1).cross(self.p2.sub(self.p1)) vector = self.p3.sub(self.p1).cross(self.p2.sub(self.p1))
n.normalize() denom = vector.norm()
self._normal = n self._normal = vector.div(denom)
return self._normal return self._normal
def plane(self): def plane(self):
...@@ -210,11 +210,9 @@ class Triangle: ...@@ -210,11 +210,9 @@ class Triangle:
self.calc_circumcircle() self.calc_circumcircle()
return self._radiussq return self._radiussq
def normal(self):
return self.p2.sub(self.p1).cross(self.p3.sub(self.p2))
def calc_circumcircle(self): def calc_circumcircle(self):
normal = self.normal() # we can't use the cached value of "normal", since we don't want the normalized value
normal = self.p2.sub(self.p1).cross(self.p3.sub(self.p2))
denom = normal.norm() denom = normal.norm()
self._radius = (self.p2.sub(self.p1).norm()*self.p3.sub(self.p2).norm()*self.p3.sub(self.p1).norm())/(2*denom) self._radius = (self.p2.sub(self.p1).norm()*self.p3.sub(self.p2).norm()*self.p3.sub(self.p1).norm())/(2*denom)
self._radiussq = self._radius*self._radius self._radiussq = self._radius*self._radius
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment