Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, l, N, ax):
self.els = []
for i in range(N):
a = finite_element(l/N, i==N-1, ax)
if i != 0:
self.els[-1].connector.link(a)
self.els.append(a)
#self.els[-1].link(zencad.assemble.unit(shape = cylinder(r=5, h=20).rotate(rvec/nrvec, nrvec)))
self.force_model = zencad.libs.rigidity.force_model_mass_point(self, 0.5, vec=(0,0,-9.81))
self.rotator = kinematic.rotator(parent=self.els[-1].connector, ax=ax)
self.input = self.els[0]
self.output = self.rotator
self.set_shape(box(12, center=True))
self.force_model = zencad.libs.rigidity.force_model_mass_point(self, 20, vec=(-1,0,1))
r0 = rod(200, 20)
mass = mass()
r0.output.link(mass)
base = zencad.assemble.unit()
base.link(r0.input)
base.relocate(rotateZ(deg(90)))
base.location_update()
fmodel = zencad.libs.rigidity.force_model_algorithm(r0.input)
fmodel.attach()
t = time.time()
for i in range(5):
fmodel.force_evaluation()
fmodel.deformation_evaluation()
fmodel.apply_deformation()
r0.input.location_update()
print(mass.global_location)
def __init__(self):
super().__init__()
self.add_shape(box(self.x, self.y, self.z, center=True).fillet(3))
self.arm_00 = self.arm()
self.arm_01 = self.arm()
self.arm_02 = self.arm()
self.arm_03 = self.arm()
self.arm_10 = self.arm()
self.arm_11 = self.arm()
self.arm_12 = self.arm()
self.arm_13 = self.arm()
self.brot_00 = zencad.libs.kinematic.rotator(location=move( self.x/4,self.y/2,0), ax=(0,0,1))
self.brot_01 = zencad.libs.kinematic.rotator(location=move( 0,self.y/2,0), ax=(0,0,1))
self.brot_02 = zencad.libs.kinematic.rotator(location=move(-self.x/4,self.y/2,0), ax=(0,0,1))
self.brot_03 = zencad.libs.kinematic.rotator(location=move(-self.x/4*2,self.y/2,0), ax=(0,0,1))
self.brot_10 = zencad.libs.kinematic.rotator(location=move( self.x/4,-self.y/2,0), ax=(0,0,1))
self.brot_11 = zencad.libs.kinematic.rotator(location=move( 0,-self.y/2,0), ax=(0,0,1))
self.brot_12 = zencad.libs.kinematic.rotator(location=move(-self.x/4,-self.y/2,0), ax=(0,0,1))
self.brot_13 = zencad.libs.kinematic.rotator(location=move(-self.x/4*2,-self.y/2,0), ax=(0,0,1))
self.rot_00 = zencad.libs.kinematic.rotator(ax=(1,0,0))
self.rot_01 = zencad.libs.kinematic.rotator(ax=(1,0,0))
self.rot_02 = zencad.libs.kinematic.rotator(ax=(1,0,0))
self.rot_03 = zencad.libs.kinematic.rotator(ax=(1,0,0))
self.rot_10 = zencad.libs.kinematic.rotator(ax=(-1,0,0))
self.rot_11 = zencad.libs.kinematic.rotator(ax=(-1,0,0))
self.rot_12 = zencad.libs.kinematic.rotator(ax=(-1,0,0))
self.rot_13 = zencad.libs.kinematic.rotator(ax=(-1,0,0))
def __init__(self):
super().__init__(inertia=inertia(mass=2))
self.add_shape(sphere(10))
self.add_force_source(zencad.libs.forces.gravity(unit=self))
def __init__(self,
parent=None,
location=zencad.transform.nulltrans(),
inertia=zencad.libs.inertia.inertia()):
super().__init__(parent, location)
self.inertia = inertia
self.force_srcs = []
self.cm_absframe_speed = screw()
self.cm_absframe_accel = screw()
def __init__(self):
super().__init__()
self.set_shape(box(12, center=True))
self.force_model = zencad.libs.rigidity.force_model_mass_point(self, 20, vec=(0,0,-9.81))
def evaluate_complex_inertia(self):
for u in self.childs:
u.evaluate_complex_inertia()
lst = [ u.complex_inertia for u in self.childs ]
lst.append(self.inertia)
self.complex_inertia = zencad.libs.inertia.complex_inertia(lst)
#!/usr/bin/env python3
from zencad import *
import zencad.libs.physics
import zencad.mbody.kinematic
import zencad.libs.forces
from zencad.libs.inertia import inertia
class body(zencad.libs.physics.physunit):
def __init__(self):
super().__init__(inertia=inertia(mass=2))
self.add_shape(sphere(10))
self.add_force_source(zencad.libs.forces.gravity(unit=self))
b_dof = zencad.mbody.kinematic.free()
b = body()
b_dof.link(b)
root = b_dof
root.reduce_forces()
root.evaluate_complex_inertia()
root.evaluate_accelerations()
print(b_dof.prereaction)
def accfunc(unit, prev):
if isinstance(unit.parent, kinematic_frame):
unit.global_frame_acceleration = unit.parent.global_accscr
if prev:
reference = prev.global_frame_acceleration_reference
spdref = prev.global_frame_speed_reference
radius = (prev.global_pose.inverse() * unit.global_pose).translation()
arm = prev.global_pose(radius)
else:
reference = screw()
spdref = screw()
arm = pyservoce.vector3()
unit.global_frame_acceleration_reference = (
zencad.libs.screw.second_kinematic_carry(reference, spdref, arm) + unit.global_frame_acceleration
)
for u in unit.childs:
accfunc(u, unit)
r = zencad.assemble.rotator(axis=(0,0,1))
a = link(axis=(0,1,0))
b = link(axis=(1,0,0))
c = link(axis=(0,1,0))
d = link(axis=(1,0,0))
e = link(axis=(0,1,0))
r.link(a)
a.rotator.link(b)
b.rotator.link(c)
c.rotator.link(d)
d.rotator.link(e)
LINKS = [a,b,c,d,e]
chain = zencad.libs.kinematic.kinematic_chain(LINKS[-1].rotator.output)
disp(a)
def preanimate(widget, animate_thread):
global CTRWIDGET, XSLD, YSLD, ZSLD
CTRWIDGET = QWidget()
layout = QVBoxLayout()
XSLD = Slider()
YSLD = Slider()
ZSLD = Slider()
layout.addWidget(XSLD)
layout.addWidget(YSLD)
layout.addWidget(ZSLD)
CTRWIDGET.setLayout(layout)