Python Physics: Building a Lagrangian Model for a Half Atwood with Spring

Поділитися
Вставка
  • Опубліковано 5 січ 2025

КОМЕНТАРІ • 3

  • @fizixx
    @fizixx 25 днів тому

    The diagrams are as tricky to do as anything else. I started building a library of shapes I can use to build things. It's handy. This is a super demo.

  • @ajejebrazor4936
    @ajejebrazor4936 25 днів тому

    Thank you! Great example! It makes me wonder if is possible to redefine some 3D objects in order to put them on sides instead of the center

  • @marcrindermann9482
    @marcrindermann9482 25 днів тому +1

    I was wondering how you connected the two strings. I've been recreating the machine before I watched the video.
    I started building my scene with the pulley at (0,0,0) and created the rest from there. I obviously used a different scale from yours but here is my solution for the arc
    r = 0.6
    points = [vp.vector(r * vp.cos(theta), r * vp.sin(theta), 0) for theta in np.linspace(0, np.pi / 2, 12)]
    self.arc = vp.curve(pos=points, radius=0.2, color=vp.color.white)
    My pulley has a radius of 0.5, my string is maybe a bit thick. I never used vpython's curve before so it was a good opportunity to test it. Advantage of leaving the pulley at the origin is that I didn't need to be careful about adding any vectors to the points I created using python's list comprehension. I never used a list comprehension with a linspace either.
    So this has been a great little project to do something I've never done before.
    In case anybody is reading this and wondering what vp., np. and self. mean. I'm using python on my local machine instead of a cloud based solution. So I've got
    import vpython as vp
    import numpy as np
    to access the objects like vp.box, vp.cylinder, np.linspace etc. And I've put my scene in a class Atwood, which is why I refer to
    self.arc, self, slider, self.string, etc.
    using the curve instead of spheres leaves tiny gaps where the arc connects to the strings but if you don't zoom in too closely it's not noticeable.