How to use the zencad.disp 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 / matrix_solver.py View on Github external
import zencad.mbody.solver
import zencad.mbody.constraits as constraits
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))
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.transform.nulltrans())
b = rigid_body(inertia=inertia(radius = pyservoce.vector3(10,0,0)), pose=zencad.transform.right(20))
a.add_view(abody)
b.add_view(bbody)

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

c1 = constraits.rotator_constrait(ax=(0,1,0))
c1.attach_positive_connection(body=a, radius=pyservoce.vector3(0,0,0))

c = constraits.rotator_constrait(ax=(0,1,0))
c.attach_positive_connection(body=b, radius=pyservoce.vector3(0,0,0))
c.attach_negative_connection(body=a, radius=pyservoce.vector3(20,0,0))
github mirmik / zencad / expers / twobody2.py View on Github external
from zencad import *

import zencad.mbody.solver
import zencad.mbody.constraits as constraits
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=3, linewidth=160)

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()
github mirmik / zencad / expers / onebody.py View on Github external
import time
from zencad import *

import zencad.mbody.solver
import zencad.mbody.constraits as constraits
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())
github mirmik / zencad / expers / twobody.py View on Github external
import zencad.elibs.solver
import zencad.elibs.constraits as constraits
from zencad.elibs.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=3, linewidth=160)

L=20

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

a = rigid_body(inertia=inertia(radius = pyservoce.vector3(0,0,0)), pose=zencad.moveX(10))
b = rigid_body(inertia=inertia(radius = pyservoce.vector3(0,0,0)), pose=zencad.moveX(30))
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,-6*10), ang=(0,6,0)))
a.set_speed(screw(lin=(0,0,0), ang=(0,0,0)))
b.set_speed(screw(lin=(10,0,0), ang=(0,0,0)))

c = constraits.spherical_rotator()
c.attach_positive_connection(body=b, pose=moveX(-10))
c.attach_negative_connection(body=a, pose=moveX(10))
github mirmik / zencad / zencad / convert / svg.py View on Github external
def read_path_A(self):
		rx=float(next(self.iter))
		ry=float(next(self.iter)) 
		x_axis_rotation=float(next(self.iter))
		large_arc_flag=float(next(self.iter)) >0.5
		sweep_flag=float(next(self.iter)) >0.5
		x=float(next(self.iter)) 
		y=float(next(self.iter))

		zencad.disp(self.wb.current)
		zencad.disp(zencad.point3(x,y))

		if abs(rx-ry) < 1e-5:
			self.wb.plane_circle_arc(rx, zencad.util.deg2rad(x_axis_rotation), large_arc_flag, sweep_flag, x, y)

		else:
			self.wb.plane_eliptic_arc(rx, ry, zencad.util.deg2rad(x_axis_rotation), large_arc_flag, sweep_flag, x, y)
github mirmik / zencad / zencad / convert / svg.py View on Github external
def read_path_A(self):
		rx=float(next(self.iter))
		ry=float(next(self.iter)) 
		x_axis_rotation=float(next(self.iter))
		large_arc_flag=float(next(self.iter)) >0.5
		sweep_flag=float(next(self.iter)) >0.5
		x=float(next(self.iter)) 
		y=float(next(self.iter))

		zencad.disp(self.wb.current)
		zencad.disp(zencad.point3(x,y))

		if abs(rx-ry) < 1e-5:
			self.wb.plane_circle_arc(rx, zencad.util.deg2rad(x_axis_rotation), large_arc_flag, sweep_flag, x, y)

		else:
			self.wb.plane_eliptic_arc(rx, ry, zencad.util.deg2rad(x_axis_rotation), large_arc_flag, sweep_flag, x, y)
github mirmik / zencad / expers / onebody_linked.py View on Github external
import zencad.elibs.solver
import zencad.elibs.constraits as constraits
from zencad.elibs.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)

bbody = zencad.cylinder(r=5, h=L, center=True).rotateY(deg(90)).moveY(40)
abbody = zencad.disp(bbody)

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

b = rigid_body(inertia=inertia(radius=pyservoce.vector3(0,0,0)), pose=zencad.moveX(10))
b.add_view(abbody)

c = constraits.spherical_rotator()
c.attach_reference(body=a, pose=left(0))

c2 = constraits.spherical_rotator()
c2.attach_reference(body=b, pose=left(10))

#a.set_speed(screw(lin=(0,0,0), ang=(200,20,0)))

solver = zencad.elibs.solver.matrix_solver(rigid_bodies=[a], constraits=[c],
github mirmik / zencad / expers / twobody2.py View on Github external
import zencad.mbody.solver
import zencad.mbody.constraits as constraits
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=3, linewidth=160)

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))