def _contains(self, other): if not is_Tuple(other) or len(other) != 3: return false v = Mat(other) p = v - self.center if self.closed: return norm(cross(p, self.direction)) <= self.slope*dot(p, self.direction) else: return norm(cross(p, self.direction)) < self.slope*dot(p, self.direction)
def _contains(self, other): if not is_Tuple(other) or len(other) != 3: return false v = Mat(other) p = v - self.center if self.closed: return norm(cross(p, self.direction))**2 <= self.radius**2 else: return norm(cross(p, self.direction))**2 < self.radius**2
def rquat2rmat(rquat): """ >>> from sympy import * >>> from symplus.strplus import init_mprinting >>> init_mprinting() >>> t = Symbol('t', positive=True) >>> simplify(rquat2rmat(rquat(pi/3, i+j))) <BLANKLINE> [ 3/4 1/4 sqrt(6)/4] [ 1/4 3/4 -sqrt(6)/4] [-sqrt(6)/4 sqrt(6)/4 1/2] >>> simplify(rquat2rmat(rquat(t, i))) <BLANKLINE> [1 0 0] [0 cos(t) -sin(t)] [0 sin(t) cos(t)] >>> simplify(rquat2rmat(rquat(t, i+k))) <BLANKLINE> [ cos(t/2)**2 -sqrt(2)*sin(t)/2 sin(t/2)**2] [sqrt(2)*sin(t)/2 cos(t) -sqrt(2)*sin(t)/2] [ sin(t/2)**2 sqrt(2)*sin(t)/2 cos(t/2)**2] """ w = rquat[0] xyz = Mat(rquat[1:]) return (1-2*norm(xyz)**2)*eye3 + 2*xyz*xyz.T + 2*w*cross(xyz)
def qmult(q1, q2): """ >>> from sympy import * >>> from symplus.strplus import init_mprinting >>> init_mprinting() >>> q1 = rquat(pi/2, i) >>> q2 = rquat(pi/3, j) >>> rquat2rmat(q1) * rquat2rmat(q2) <BLANKLINE> [ 1/2 0 sqrt(3)/2] [sqrt(3)/2 0 -1/2] [ 0 1 0] >>> rquat2rmat(qmult(q1, q2)) <BLANKLINE> [ 1/2 0 sqrt(3)/2] [sqrt(3)/2 0 -1/2] [ 0 1 0] """ w1 = q1[0] xyz1 = Mat(q1[1:]) w2 = q2[0] xyz2 = Mat(q2[1:]) w = w1*w2 - dot(xyz1, xyz2) xyz = w1*xyz2 + w2*xyz1 + cross(xyz1, xyz2) return Mat([w] + xyz[:])
def as_abstract(self): """ >>> from sympy import * >>> from symplus.strplus import init_mprinting >>> init_mprinting() >>> SemiInfiniteCone().as_abstract() {(x, y, z) | sqrt(x**2 + y**2) < z} >>> SemiInfiniteCone(5, [0,0,0], [3,4,0]).as_abstract() {(x, y, z) | sqrt(z**2 + (4*x/5 - 3*y/5)**2) < 3*x + 4*y} """ p = r - self.center if self.closed: expr = norm(cross(p, self.direction)) <= self.slope*dot(p, self.direction) else: expr = norm(cross(p, self.direction)) < self.slope*dot(p, self.direction) return AbstractSet((x,y,z), expr)
def as_abstract(self): """ >>> from sympy import * >>> from symplus.strplus import init_mprinting >>> init_mprinting() >>> InfiniteCylinder().as_abstract() {(x, y, z) | x**2 + y**2 < 1} >>> InfiniteCylinder(2, [0,0,0], [0,1,1]).as_abstract() {(x, y, z) | x**2 + (-sqrt(2)*y/2 + sqrt(2)*z/2)**2 < 4} """ p = r - self.center if self.closed: expr = norm(cross(p, self.direction))**2 <= self.radius**2 else: expr = norm(cross(p, self.direction))**2 < self.radius**2 return AbstractSet((x,y,z), expr)
def rmat_k2d(d): d = normalize(d) if d == k: rot = eye(3) elif d == -k: rot = diag(1,-1,-1) else: rot = rquat2rmat(rquat(acos(dot(k, d)), cross(k, d))) return rot
def as_abstract(self): """ >>> from sympy import * >>> from symplus.strplus import init_mprinting >>> init_mprinting() >>> Revolution(lambda h, s: h**2<s**2).as_abstract() {(x, y, z) | z**2 < x**2 + y**2} >>> Revolution(lambda h, s: h+1<s**2, [0,0,0], [3,4,0]).as_abstract() {(x, y, z) | 3*x/5 + 4*y/5 + 1 < z**2 + (4*x/5 - 3*y/5)**2} """ p = r - self.center expr = self.func(dot(p, self.direction), norm(cross(p, self.direction))) return AbstractSet((x,y,z), expr)
def _contains(self, other): if not is_Tuple(other) or len(other) != 3: return false v = Mat(other) p = v - self.center return self.func(dot(p, self.direction), norm(cross(p, self.direction)))