A 'Big ' Challenge for groups of programmers has been created by Nonki. We are recruiting during August for development in September.
In summary the challenge is to create a marionette puppet in Small Basic, here is an extract of the challenge:
"create a marionette (or puppet) per group which can be moved by user interaction"
If you fancy working on this in a group effort, whatever your programming level, then add a post to the Small Basic Big Challenge Thread. Working in a group can make learning programming more fun.
This blog outlines some ideas for the physics part of the challenge which could be a bit tricky, other aspects of the challenge not addressed here include:
Basically, a marionette will consist of limbs connected together. We can say that each limb will have a certain length (L) and perhaps a mass (M). The limbs could all have equal mass or have a mass dependent on the limb size in some way.
The limbs are connected at joints (or nodes), so each node has one or more limbs connected to it.
The simplest analogy is to think of the limbs as connected springs to help calculate their movements.
Here are some physical principals.
Here is a schematic picture of a node at (X,Y) connected to 3 limbs.
The natural length of the limbs are shown in blue (L1, L2 and L3)
Limbs 1 and 2 are stretched beyond this length by E1 and E2, while limb 3 is compressed by distance C3.
Each force vector can be resolved into X and Y components, and added separately with a contribution to each node from its connected limbs.
Where a and b are scaling factors and Lext is the extended (or compressed) length of a limb. If compression is not used, then only terms where Lext > L are included.
The exact physics isn't that critical, just the basic principals.
The net force vectors (Fx,Fy) for each node are calculated, then used to move the nodes towards stationary (zero net force) positions. We can move the nodes by an amount proportional to the net forces and their directions, then recalculate everything with the updated node positions.
, where c is another scaling factor.
In some cases, stability may be improved by averaging (Fx,Fy) from one step to the next to reduce oscillation about a zero force solution.
If the scheme forces are well scaled, then after a few steps the marionette nodes will be balanced with zero net force, until we move the strings. The top of the strings are fixed positions and are moved only by the user in some way.