Exemple #1
0
    def add_triedron(self,
                     length=10,
                     width=1,
                     arrlen=1,
                     xcolor=pyservoce.red,
                     ycolor=pyservoce.green,
                     zcolor=pyservoce.blue):
        self.xaxis = pyservoce.draw_arrow(pyservoce.point3(0, 0, 0),
                                          pyservoce.vector3(length, 0, 0),
                                          clr=xcolor,
                                          arrlen=arrlen,
                                          width=width)
        self.yaxis = pyservoce.draw_arrow(pyservoce.point3(0, 0, 0),
                                          pyservoce.vector3(0, length, 0),
                                          clr=ycolor,
                                          arrlen=arrlen,
                                          width=width)
        self.zaxis = pyservoce.draw_arrow(pyservoce.point3(0, 0, 0),
                                          pyservoce.vector3(0, 0, length),
                                          clr=zcolor,
                                          arrlen=arrlen,
                                          width=width)

        self.dispobjects.append(self.xaxis)
        self.dispobjects.append(self.yaxis)
        self.dispobjects.append(self.zaxis)
Exemple #2
0
 def __init__(self, axis, mul=1, **kwargs):
     super().__init__(**kwargs)
     self.coord = 0
     self.axis = pyservoce.vector3(axis)
     self.axis = self.axis.normalize()
     self.mul = mul
     self.axmul = self.axis * self.mul
Exemple #3
0
def vector3(*args):
    args = [evalcache.unlazy_if_need(a) for a in args]
    if len(args) == 1:
        if args[0] is None:
            return vector3(0, 0, 0)
        return vector3(*args[0])
    return pyservoce.vector3(*args)
Exemple #4
0
    def to_halfspace_if_need(x):
        if isinstance(x, (tuple, list, pyservoce.vector3)):
            vec = pyservoce.vector3(x)
            return (
                zencad.transform.translate(*vec) *
                zencad.transform.short_rotate(fromvec=(0, 0, 1), tovec=vec))(
                    pyservoce.halfspace())

        elif isinstance(x, (int, float)):
            return pyservoce.halfspace().up(x)

        return x
Exemple #5
0
    def __init__(self,
                 rigid_bodies,
                 constraits,
                 workspace_scale=1,
                 gravity=pyservoce.vector3(0, 0, 0),
                 world_dempher=0,
                 closing_compensation=True):

        self.rigid_bodies = rigid_bodies
        self.constraits = constraits
        self.workspace_scale = workspace_scale
        self.gravity = gravity
        self.world_dempher = world_dempher
        self.closing_compensation = closing_compensation
Exemple #6
0
    def active_forces(self):
        NR = len(self.rigid_bodies)
        N = NR * 6

        S = numpy.zeros((N, 1))

        gravs = []
        if self.gravity != pyservoce.vector3(0, 0, 0):
            for i, r in enumerate(self.rigid_bodies):
                arm = -r.reference_inertia.radius
                scr = screw(lin=self.gravity, ang=(
                    0, 0, 0)).force_carry(arm) * r.reference_inertia.mass
                gravs.append(scr.npvec_lin_first())

        P = np.concatenate(gravs).reshape((N, 1))

        return S + P
Exemple #7
0
	def __init__(self, mass=1, matrix=pyservoce.matrix33(1,1,1), radius=pyservoce.vector3(0,0,0)):
		self.radius = pyservoce.vector3(radius)
		self.matrix = matrix
		self.invmatrix = self.matrix.inverse()
		self.mass = mass
Exemple #8
0
 def set_coords(self, coords, **kwargs):
     self.x = coord[0]
     self.y = coord[1]
     self.output.relocate(
         pyservoce.translate(pyservoce.vector3(self.x, self.y, 0)),
         **kwargs)
Exemple #9
0
 def senses(self):
     return ((pyservoce.vector3(1, 0, 0), pyservoce.vector3()),
             (pyservoce.vector3(0, 1, 0), pyservoce.vector3()))
Exemple #10
0
    def sensivity(self):
        """Возвращает тензор производной по положению
		в собственной системе координат в формате (w, v)"""
        return (pyservoce.vector3(), self.axmul)
Exemple #11
0
def vector3(*arg):
    if isinstance(arg[0], pyservoce.vector3):
        return arg[0]

    return pyservoce.vector3(*arg)