How to use the zencad.libs.screw.screw function in zencad

To help you get started, we’ve selected a few zencad examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mirmik / zencad / expers / twobody2.py View on Github external
L=20

body = zencad.cylinder(r=5, h=L).rotateY(deg(90))
body2 = zencad.cylinder(r=5, h=L).rotateY(deg(90))
abody = zencad.disp(body)
bbody = zencad.disp(body2)

a = rigid_body(inertia=inertia(radius = pyservoce.vector3(10,0,0)), pose=zencad.moveX(0))
b = rigid_body(inertia=inertia(radius = pyservoce.vector3(10,0,0)), pose=zencad.moveX(20))
a.add_view(abody)
b.add_view(bbody)

#b.pose=zencad.transform.right(20) #* zencad.transform.rotateY(deg(20))
a.set_speed(screw(lin=(0,0,0), ang=(0,0,0)))
b.set_speed(screw(lin=(0,0,10), ang=(0,0,0)))

c = constraits.spherical_rotator()
c.attach_positive_connection(body=b, pose=moveX(0))
c.attach_negative_connection(body=a, pose=moveX(20))

#c1 = constraits.spherical_rotator()
#c1.attach_reference(body=a, pose=moveX(0))

solver = zencad.mbody.solver.matrix_solver(rigid_bodies=[a,b], constraits=[c])
solver.update_views()
solver.update_globals()

#exit(0)
starttime = time.time()
lasttime = starttime
noinited = True
github mirmik / zencad / zencad / libs / screw.py View on Github external
def from_trans(trans):
		lin = trans.translation()
		ang = trans.rotation().rotation_vector()
		return screw(lin=lin, ang=ang)
github mirmik / zencad / zencad / libs / treedy.py View on Github external
def calculate_kinframe_frame_speeds_accelerations(self):
		for kinframe in self.kinematic_frames:
			kinframe.global_frame_speed = screw()
			kinframe.global_frame_acceleration = screw()
			for u in kinframe.pre_kinematic_frames:
				arm = kinframe.global_pose.translation() - u.global_pose.translation()
				kinframe.global_frame_speed += u.global_spdscr.kinematic_carry(arm) 
				kinframe.global_frame_acceleration += \
					zencad.libs.screw.second_kinematic_carry(iacc=u.global_accscr, ispd=u.global_spdscr, arm=arm)
github mirmik / zencad / zencad / libs / screw.py View on Github external
def from_array(a):
		return screw(ang=(a[3], a[4], a[5]), lin=(a[0], a[1], a[2]))
github mirmik / zencad / zencad / libs / screw.py View on Github external
def __sub__(self, oth):
		return screw(self.ang - oth.ang, self.lin - oth.lin)
github mirmik / zencad / zencad / libs / screw.py View on Github external
def __mul__(self, oth):
		return screw(self.ang * oth, self.lin * oth)
github mirmik / zencad / zencad / libs / HIDE / phys.py View on Github external
def local_force(self):
		return screw(lin=(0,0,0), ang=(0,0,0))
github mirmik / zencad / zencad / libs / screw.py View on Github external
def copy(self):
		return screw(ang=self.ang, lin=self.lin)
github mirmik / zencad / zencad / libs / HIDE / assemble_addons.py View on Github external
def func(unit):
		unit.global_frame_speed_reference = screw()
		unit.global_frame_speed = screw()

		unit.global_frame_acceleration_reference = screw()
		unit.global_frame_acceleration = screw()


		for u in unit.childs:
			func(u)
github mirmik / zencad / expers / onebody.py View on Github external
from zencad.mbody.rigid_body import rigid_body
#import zencad.mbody.kinematic as kinematic
from zencad.libs.inertia import inertia
from zencad.libs.screw import screw
numpy.set_printoptions(suppress=True)
numpy.set_printoptions(precision=5, linewidth=160)

L=20

body = zencad.cylinder(r=5, h=L).rotateY(deg(90))
abody = zencad.disp(body)

a = rigid_body(inertia=inertia(radius=pyservoce.vector3(10,0,0)), pose=zencad.transform.nulltrans())
a.add_view(abody)

a.set_speed(screw(lin=(0,0,0), ang=(2,2,2)))

solver = zencad.mbody.solver.matrix_solver(rigid_bodies=[a], constraits=[])
solver.update_views()
solver.update_globals()

print("mass matrix")
print(solver.mass_matrix())
print("constrait matrix")
print(solver.constrait_matrix()[0])
print("inertia_forces")
print(solver.inertia_forces())

accs, react = solver.solve()

print("acc")
print(accs)