예제 #1
0
 def projection(self, obj):
     assert isinstance(obj, baseGeometryObject), 'incorrect object for projection'
     if isinstance(obj, Line):
         # TODO: remove 0.0 for future Python 3.X versions
         tmp = dot(self-obj.basePoint, obj.direction)
         if isinstance(tmp, oofun): tmp.size = 1
         tmp1 = obj.direction*tmp / (0.0+sum(obj.direction**2))
         tmp2 = obj.basePoint
         if type(tmp1) == ooarray: # hence tmp2 is array
             tmp2 = tmp2.view(ooarray)
         return Point(tmp1+tmp2)
     elif isinstance(obj, Plane):
         d1, d2 = obj.directions
         bp = obj.basePoint
         a = sum(d1**2)
         b = d = dot(d1, d2)
         e = sum(d2**2)
         c = dot(self-bp, d1)
         f =  dot(self-bp, d2)
         delta = a*e-b*d + 0.0 # TODO: remove 0.0 when Python 2.x will be deprecated
         alpha = (c*e-b*f) / delta
         beta = (a*f-c*d)/delta
         return Point(bp + alpha * d1 + beta * d2)
     else:    
         raise SpaceFuncsException('not implemented for this geometry object yet')
예제 #2
0
 def projection(self, obj):
     assert isinstance(
         obj, baseGeometryObject), 'incorrect object for projection'
     if isinstance(obj, Line):
         # TODO: remove 0.0 for future Python 3.X versions
         tmp = dot(self - obj.basePoint, obj.direction)
         if isinstance(tmp, oofun): tmp.size = 1
         tmp1 = obj.direction * tmp / (0.0 + sum(obj.direction**2))
         tmp2 = obj.basePoint
         if type(tmp1) == ooarray:  # hence tmp2 is array
             tmp2 = tmp2.view(ooarray)
         return Point(tmp1 + tmp2)
     elif isinstance(obj, Plane):
         d1, d2 = obj.directions
         bp = obj.basePoint
         a = sum(d1**2)
         b = d = dot(d1, d2)
         e = sum(d2**2)
         c = dot(self - bp, d1)
         f = dot(self - bp, d2)
         delta = a * e - b * d + 0.0  # TODO: remove 0.0 when Python 2.x will be deprecated
         alpha = (c * e - b * f) / delta
         beta = (a * f - c * d) / delta
         return Point(bp + alpha * d1 + beta * d2)
     else:
         raise SpaceFuncsException(
             'not implemented for this geometry object yet')
예제 #3
0
def skewLinesNearestPoints(line1, line2):
    assert isinstance(line1, Line) and isinstance(line2, Line)
    p1, p2 = line1.basePoint, line2.basePoint
    d1, d2 = line1.direction, line2.direction
    Delta = sum(d1**2)*sum(d2**2) - dot(d1, d2)**2
    Delta1 = dot(d2, p1-p2) * dot(d1, d2) - dot(d1, p1-p2) * sum(d2**2)
    Delta2 = dot(d2, p1-p2) * sum(d1**2) - dot(d1, d2) * dot(d1, p1-p2)
    t1 = Delta1 / Delta
    t2 = Delta2 / Delta
    for t in [t1, t2]:
        if isinstance(t, oofun): t.size = 1
    return Point(p1+t1*d1), Point(p2+t2*d2)
예제 #4
0
def skewLinesNearestPoints(line1, line2):
    assert isinstance(line1, Line) and isinstance(line2, Line)
    p1, p2 = line1.basePoint, line2.basePoint
    d1, d2 = line1.direction, line2.direction
    Delta = sum(d1**2) * sum(d2**2) - dot(d1, d2)**2
    Delta1 = dot(d2, p1 - p2) * dot(d1, d2) - dot(d1, p1 - p2) * sum(d2**2)
    Delta2 = dot(d2, p1 - p2) * sum(d1**2) - dot(d1, d2) * dot(d1, p1 - p2)
    t1 = Delta1 / Delta
    t2 = Delta2 / Delta
    for t in [t1, t2]:
        if isinstance(t, oofun): t.size = 1
    return Point(p1 + t1 * d1), Point(p2 + t2 * d2)
예제 #5
0
 def _circumSphereCenter(self):
     a, b, c = self.reducedVertices
     bc, ca, ab = self.reducedVerticesCrossProduct
     return (sum(a**2) * bc + sum(b**2) * ca + sum(c**2) * ab) / (2.0*dot(a, bc)) + self.vertices[-1]