Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def interpolate(pnts, tangs=[], closed=False):
return pyservoce.interpolate_curve3(points(pnts), vectors(tangs), closed)
def hexahedron(r=1, a=None, shell=False):
if a is None:
a = r / math.sqrt(3) * 2
he = a * 1 / 2; # half the edge length
return zencad.polyhedron(
pnts=points([
[-he, -he, -he], # 0
[-he, -he, he], # 1
[-he, he, -he], # 2
[-he, he, he], # 3
[ he, -he, -he], # 4
[ he, -he, he], # 5
[ he, he, -he], # 6
[ he, he, he], # 7
]),
faces=[
[0, 1, 3, 2],
[4, 5, 7, 6],
[2, 3, 7, 6],
[0, 1, 5, 4],
[0, 2, 6, 4],
[1, 3, 7, 5],
def interpolate2(lst, degmin=3, degmax=7):
if isinstance(lst[0][0], pyservoce.point3):
return pyservoce.interpolate2(lst, degmin=degmin, degmax=degmax)
else:
lst = [ points(l) for l in lst ]
return pyservoce.interpolate2(lst, degmin=degmin, degmax=degmax)
def polyhedron(pnts, faces, shell=False):
pnts = points(pnts)
shl = pyservoce.polyhedron_shell(pnts, faces)
if shell:
return shl
else:
return shl.fill()
def octahedron(r=1, a=None, shell=False):
if a is None:
a = r / math.sqrt(2) * 2
he = a * 1 / 2; # half the edge length
c = a * math.sqrt(2) / 2; # circumsphere radius
return zencad.polyhedron(
pnts=points([
[ 0, 0, c], # 0: top
[-he, he, 0], # 1: front left
[ he, he, 0], # 2: front right
[ he, -he, 0], # 3: rear right
[-he, -he, 0], # 4: rear left
[ 0, 0, -c], # 5: bottom
]),
faces=[
[1, 0, 2], # top front
[2, 0, 3], # top right
[3, 0, 4], # top rear
[4, 0, 1], # top left
[5, 1, 2], # bottom front
[5, 2, 3], # bottom right
[5, 3, 4], # bottom rear
[4, 1, 5], # bottom left
def polysegment(lst, closed=False):
return pyservoce.polysegment(points(lst), closed)
def bezier(pnts, weights=None):
"""Построение дуги круга по трем точкам"""
pnts = points(pnts)
if weights:
return pyservoce.bezier(pnts, weights)
else:
return pyservoce.bezier(pnts)
def polygon(pnts, wire=False):
if wire:
return pyservoce.polysegment(points(pnts), True)
else:
return pyservoce.polygon(points(pnts))
def bspline(pnts, knots, muls, degree, periodic=False, check_rational=True, weights=None):
"""Построение дуги круга по трем точкам"""
pnts = points(pnts)
if weights:
return pyservoce.bspline(
pnts=pnts,
knots=knots,
weights=weights,
multiplicities=muls,
degree=degree,
periodic=periodic,
check_rational=check_rational)
else:
return pyservoce.bspline(
pnts=pnts,
knots=knots,
multiplicities=muls,
degree=degree,