How to use the zencad.cylinder 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 / test / caching / cylinder.py View on Github external
#!/usr/bin/env python3
#coding: utf-8

import zencad
m0 = zencad.cylinder(r = 10, h = 20)

zencad.display(m0)
zencad.show()
github mirmik / zencad / expers / matrix_solver.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))
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))
github mirmik / zencad / zencad / examples / 4.Assemble / robot.py View on Github external
def __init__(self):
        super().__init__()

        arm_model = (
        	zencad.box(self.aw, self.aw, self.h / 2, center=True)
        		.down(self.h / 4 - self.aw / 2)
        		.rotateY(deg(90))
        	)
        body_model = zencad.cylinder(r=self.r, h=self.h)
        arm_translate = translate(self.r + self.aw / 2, 0, self.h / 6 * 4) * rotateY(-deg(90))

        self.add_shape(body_model)

        #self.right_arm_connector = zencad.controllers.RotateConnector(
         #   parent=self, child=arm_model, location=arm_translate
        #)

        self.left_arm_connector = zencad.assemble.spherical_rotator(parent=self, location=mirrorYZ() * arm_translate)
        self.right_arm_connector = zencad.assemble.spherical_rotator(parent=self, location=arm_translate)

        self.left_arm_connector.output.add_shape(arm_model)
        self.right_arm_connector.output.add_shape(arm_model)

        # print("HEAD_CONNECTOR!!!")
        head = HeadAssemble()
github mirmik / zencad / expers / twobody.py View on Github external
import time
from zencad import *

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

import zencad.elibs.solver
import zencad.elibs.constraits as constraits
from zencad.elibs.rigid_body import rigid_body
#import zencad.libs.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))
body3 = zencad.cylinder(r=5, h=L, center=True).rotateY(deg(90))
abody = zencad.disp(body)
bbody = zencad.disp(body2)
bbody3 = zencad.disp(body3)

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

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

c2 = constraits.spherical_rotator()