Tuesday, 3 May 2016

A mass, bar, point and a spring


I am making a simple little program that needs to simulate a physics concept. However, I am not exactly sure how the physics concept actually works.


I really like diagrams to illustrate my physics questions, so I included one:


My amazingly terrible picture illustrating what my question entails. Please do not judge my terrible art skills.


In the diagram:



  1. $m$ = The mass of interest

  2. Connecting $m$ to $p$ (the red dot, denoted as position) is a non-flexible bar with a swing joint at $p$


  3. The green spiral is meant to represent the spring that coerces the bar (and mass $m$) referenced in statement 2 to come to an equilibrium

  4. The dashed blue lines represent a simple constraint on how far the bar can travel

  5. The arrows around $p$ are a reminder that $p$ can both move on both the $x$ and $y$-axis as well as rotate (these forces come from external entities not shown in the diagram).

  6. I am currently ignoring gravity for now. However it would be nice to know how to apply it.

  7. $p$ is unaffected (both positional and rotational) by the events of $m$ and the bar.


The diagram shows the system in an equilibrium. However, when forces applied to either $m$ or $p$ the spring in the system will attempt to bring $m$ back to an equilibrium.


I am honestly not worried about statement #4 (the constraints). I was going to add in a simple angular constraint to ensure the bar did not exceed the maximum angle of travel. The large component of this question lies in statement #5. I am not sure how to translate mass $m$ given a movement from $p$, let alone rotating $p$.


Ultimately my question comes to: what is the equation(s) I should use to simulate the system? I believe I will have to solve this problem using Kinetic Energy $KE$ / Potential Energy $PE$, correct me if I am wrong. I have a few ideas on the equations to use but not much else:




  1. Kinetic Energy of a mass: $KE_{m} = \frac{1}{2}mv^2$

  2. Potential Energy of a spring: $PE_{spring} = \frac{1}{2}kx^2$

  3. Conservation of Energy: $\sum{KE} + \sum{PE} + W = 0$


But I am confused how I can incorporate those equations with $p$ which does not need a mass. And how to translate the forces to the mass appropriately. (Basically the entire thing)




Based on @Seans suggestion, instead of calculating the equation using conservation of energy, forces are used. So here is what I have so far:


First I removed some of the complexity to get a starting position to work with. I removed the spring completely and attempted to find what would happen to the mass $m$ should an arbitrary velocity $v$ be provided to $p$. The mass $m$ in such scenario (lacking any additional forces). To illustrate my progress I implemented a JsFiddle dump of each step:


-- JS Test 1 --


First I wanted to get something working with the red dot following the mouse and the mass that follows the red dot based on a fixed distance away (the bar). This does not account for much anything else, no momentum/forces/friction. The mass feels like a magnetite on a metal plate as you attempt to push and pull it along with a stick. This was fine for a rough mock-up, now to implement some physics in the second test.



-- In progress --


Second I wanted to illustrate some forces acting upon the mass. For example, you should swing the mass with your mouse. Still working on this one, so hang tight.




No comments:

Post a Comment