5
\$\begingroup\$

I would like a series of objects to behave in similar manner to a series of connected gears.

This means that each black object in the diagram below will rotate at a speed based on the ratio of their radius compared to their parent's radius.

Circles act like gears

The problem is how can I determine a sensible parent child hierarchy algorithmically?

Is there a tried and tested mathematical procedure for such a task?

\$\endgroup\$
  • 4
    \$\begingroup\$ There are no parents or children - only neighbors. One real challenge here is that you might be able to map what's touching what, but the issue is deciding if it's actually a feasible configuration. You might find that a gear has two neighbors, both of which are moving. The two neighbors have to apply a matching action onto the shared gear - ie, both making it spin at the same speed, and in the same direction. \$\endgroup\$ – Tim Holt Aug 1 '14 at 21:25
4
\$\begingroup\$

Sorry everything would look nicer if latex formatting would be possible.

Let's consider three gears: G1, G2 and G3.

Now each gear has a given radius r1, r2 and r3. The problem is to find the angular velocity for each gear (denoted av1, av2 and av3). From a physics course we know that the tangent velocity v is proportional to the radius: v1 = av1 * r1.

Now, if a given gear, say G1, is connectad to a second gear G2, then the tangent velocities match: v1=v2=v, where v is the overall velocity of the system, a global parameter for a system of connected gears.

Now it follows that av1 * r1 = v so av1 = v/r1 for each gear. That way you can find out the angular velocity of all gears in a system.

The next step is finding the rotation direction. For this, simply choose a gear (say G1), fix the rotation direction (say to +av1), look which gears are connected to it. If G2 is connected to it, its angular velocity is -av2.

There is still the problem of the clinch situation:

For small-scale problems I would advise to simply do this gear-wise for all gears: Then, if for any gear you want to set a different direction than already set - set all angular velocity values (or the system velocity) to 0 - the system is "jammed"!

You simply do this for each set of connected gears.

Its not a very sophisticated method to do this but I think it should work. :-)

One more comment: you can easily save the gear structure in the so-called "adjacency matrix". It is a matrix that is 1, if gear i is connected to gear j and 0 otherwise. As an example, take the 3x3 matrix consisting of only ones - where each of three gears is connected to the other - it represents a jammed system! In your scripts, use the adjacency matrix to write the script that determines the rotation directions!

\$\endgroup\$
0
\$\begingroup\$

You might be using a net-like structure, where each gear knows about all gears it is in contact with.

When you need to apply a rotation, you pick a master gear that you start with and recursively rotate all its neighbors.

If you want an algorithm to find a master gear - there's really none. You just pick gears that has only one neighbor and choose one of them (e.g. by it's size or net distance from other gears).

Note, that you need to deal with clinch situations, when you have three gears interlocking each other.

\$\endgroup\$
  • 1
    \$\begingroup\$ If you want an algorithm to find a master gear - there's really none. This is what I was having issues with to begin with. Now that I have abandoned the idea that one can be found, it makes the solution much easier to attain. \$\endgroup\$ – user1423893 Sep 2 '14 at 18:54
-1
\$\begingroup\$

This seems like a standard engineering problem. It is definitely possible to determine the rotations of all gears, even with multiple drivers. Read up on Gear Trains. If this is a big part of your work, it might be worth picking up a book on engineering dynamics. Good luck!

\$\endgroup\$
  • \$\begingroup\$ This does not seem to answer the question. It would be better to prove that it is possible to solve the system, rather than simply declaring it to be so. Also, the information from your link that you believe to be relevant should be included in your answer with citation, see gamedev.stackexchange.com/help/referencing. \$\endgroup\$ – Seth Battin Nov 3 '14 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.