Example #1
0
 def projection(self, obj):
     assert isinstance(obj, Plane)
     
     # TODO: maybe involve normalization of direction norm?
     r = Line(self.basePoint.projection(obj), (self.basePoint+self.direction).projection(obj))
     r.direction /= norm(r.direction)
     return r
Example #2
0
    def projection(self, obj):
        assert isinstance(obj, Plane)

        # TODO: maybe involve normalization of direction norm?
        r = Line(self.basePoint.projection(obj),
                 (self.basePoint + self.direction).projection(obj))
        r.direction /= norm(r.direction)
        return r
Example #3
0
def _contains(obj, p, tol, inside = False):
    assert isinstance(p, Point), 'implemented only for Point yet'
    if isinstance(obj, (Line, Plane)):
        P = p.projection(obj)
        if isinstance(P, ndarray) and str(p.dtype) != 'object':
            return norm(p - P) <= tol
        else:
            return (p == P)(tol=tol)
    elif isinstance(obj, (Ring, Orb)):
        if isinstance(p, ndarray) and str(p.dtype) != 'object':
            return p.distance(obj.center) - obj.radius <= tol if inside else -tol <= p.distance(obj.center) - obj.radius <= tol
        else:
            return (p.distance(obj.center) <= obj.radius if inside else p.distance(obj.center) == obj.radius)(tol=tol)
    else:
        assert 0, 'method contains() is unimplemented for type %s' % type(obj)
Example #4
0
def _contains(obj, p, tol, inside=False):
    assert isinstance(p, Point), 'implemented only for Point yet'
    if isinstance(obj, (Line, Plane)):
        P = p.projection(obj)
        if isinstance(P, ndarray) and str(p.dtype) != 'object':
            return norm(p - P) <= tol
        else:
            return (p == P)(tol=tol)
    elif isinstance(obj, (Ring, Orb)):
        if isinstance(p, ndarray) and str(p.dtype) != 'object':
            return p.distance(
                obj.center
            ) - obj.radius <= tol if inside else -tol <= p.distance(
                obj.center) - obj.radius <= tol
        else:
            return (p.distance(obj.center) <= obj.radius if inside else
                    p.distance(obj.center) == obj.radius)(tol=tol)
    else:
        assert 0, 'method contains() is unimplemented for type %s' % type(obj)
Example #5
0
 def _incenter(self):
     a, b, c = self.reducedVertices
     bc, ca, ab = self.reducedVerticesCrossProduct
     return (a * norm(bc) + b * norm(ca) + c * norm(ab)) / (norm(bc)+norm(ca)+norm(ab)+norm(bc+ca+ab)) + self.vertices[-1]
Example #6
0
 def _circumSphereRadius(self):
     a, b, c = self.reducedVertices
     bc, ca, ab = self.reducedVerticesCrossProduct
     return norm(sum(a**2)*bc + sum(b**2)*ca + sum(c**2)*ab) / (12.0 * self.V)
Example #7
0
 def _insphereRadius(self):
     a, b, c = self.reducedVertices
     bc, ca, ab = self.reducedVerticesCrossProduct
     return 6.0*self.V / (norm(bc) + norm(ca) + norm(ab) + norm(bc+ca+ab))