Dynamics V – 1 Crash Course on Math and Physics

Understanding cloth and having a mental model of the physics involved is necessary but not sufficient to make effective and efficient simulating systems. Creating those systems is a world in its own right. Especially those with an engineer’s way of looking at things might be interested in this mini tour through the deep down dungeons. Crash Course on Math & Physics (this page)and Crash Course on Sims & Settings(next)really are the math and physics loaded chapters. Any use of the underground escape tunnel brings you into Muppets Lab “where the future is made today”. You have been warned.

Some people immediately zap away when they see even a two-character formula coming along, others insist in getting the rough engineering treatment to enhance their understanding. This chapter is for the latter part of the audience, although I can recommend the conclusions to everyone.

I’ll start with some math first because 1) it simplifies handling the formulas and 2) in the forums people have stated to have some issues handling and grasping it. Second I’ll do the physics, from an electrical point of view. This gives the proper resulting formulas in an easy way, but it’s too far away from our actual simulations. So third, I’ll present the physics from a mechanical point of view. Similar formulas but much closer to our actual cloth simulation.

Then, fourth, I’ll consider the simulation algorithms themselves. Finally, I’ll present some conclusions that help you further in handling the Poser parameters and cloth simulation.

Complex Calculations

In order to handle straightforward object motion, steady currents and flows, I can simply deal with real numbers. But handling disruptions, oscillations, alternating current and more becomes a lot easier when I extent my repertoire to imaginary and complex numbers.
In that area, the magic bullet is called ‘i’ with the property i2 = -1. I don’t have to understand it, it’s there, period. Multiplying a real number b by i turns it into the imaginary i*b (or: ib for short), and repeating the operation turns it into i*i*b = i2b = -b which brings me back into the real world again. When I mix a real number a and an imaginary ib I get a complex number a+ib, and I can do all adding and subtraction while keeping the real and imaginary worlds separate:
(a+ib) + (c+id) = (a+c) + i(b+d).
Like I can represent real numbers on a straight line, I can represent complex numbers in a simple plane. I can use dots or arrows to them, and adding and subtraction behave like simple adding and subtracting those arrows as in vector algebra.

Complex numbers however are not very friendly in multiplication and handling powers, exponentials and logarithms. As you can see in
(a+ib)*(c+id) = ac + ibc + iad + i2bd = (ac-bd) +i(bc+ad)
real and imaginary parts of the numbers get mixed, which might turn longer calculations into a sheer mess.

The vector approach however gives us an alternative. Instead of considering the x and y components of the vector, we can consider its length R and angle q with the horizontal axis. This makes a+ib equivalent to R*[cos(q)+isin(q)]. Adding and subtracting from this approach becomes a nightmare, but multiplication, division and more becomes easy. Multiplication is: multiply the lengths and add the angles, which follows in a straightforward way from classic geometry (I’ll save you the details).

To simplify our tool even more, I use natural exponents and logarithms to rewrite R to er (or r=ln(R) ), and especially (cos(q) + isin(q)) to eiq. In other words, a+ib becomes e(r+iq) where r=ln(sqrt(a2+b2)) and q= arctan(b/a). This is handy, since multiplication of values is equivalent to the addition of exponents, and taking powers is equivalent to multiplying exponents, so (e(r+iq) * e(s+it) => e[(r+s)+i(q+t)] and [a+ib]N => [e(r+iq)] N => eN(r+iq).

So, with this dirty trick, the issues of complex multiplication and power-lifting are reduced to addition and simple multiplication. That’s a gain.

This is the basic tool, now the application of it in physics. Alternating currents, oscillating movements and the like can be described as x(t) = Rcos(wt) where R is the amplitude, and w=2 pi f, for oscillating frequency f. Each time wt makes a multiple of 2 pi, or each time ft makes a whole number, the oscillation starts anew. Now it has become a small step to state that the oscillation we see is just the real world part of a complex movement, which also has an imaginary component in a world we can or cannot imagine J.
But as a whole, its described with x(t) = Reiwt or even with x(t) = e(r+iwt).

The main reason for doing this, is that we need time-derivatives (and integrals) like dx/dt to get speed, acceleration and more. But the classical approach presents us a plethora of sine and cosine functions, and we really need a lot of geometry to get understandable results. In the new approach, we don’t.

When x(t) = e(r+iwt) then dx/dt = iw * e(r+iwt), so d2x/dt2 = -w2 * e(r+iwt), from position to velocity to acceleration,
but also ∫xdt = 1/iw e(r+iwt) and so ∫∫xdt2 = -1/w2 e(r+iwt) , from acceleration to velocity to position.

Going Electrical

In abstraction, basic physics considers a ‘field’ and a ‘thing’, and moving the thing against the field requires energy (from us or from the thing itself), while moving the thing along the field returns that energy back. One unit of field times one unit of thing make 1 Joule of energy, and if I do so every second it requires or generates 1 Joule per second or: 1 Watt of power.

Less abstract, in electricity the ‘field’ is electric potential (char: V) determined in Volt and the ‘thing’ is electrical charge (char: Q) determined in Coulomb. When such an amount of charge passes a measuring point within 1 second, we’ve got an electrical current of 1 Coulomb per second, or: 1 Ampere.
When I move such a charge to a place with a 1 Volt higher potential it requires 1 Joule (char: E, in formula: E=V*Q), and when I do so every second it requires a power of 1 Watt (char W, in formula: W = V*I). Especially this last formula on electrical power might hang somewhere in your memory, resulting from a physics class or so.

When I move a charge from one place to another, bridging a potential, it becomes harder for the next portion of charge to do the same. The source of the charges becomes short due to the displacement, or: anti-charged and as we know opposite charges pull each other. The destination of the charges gets a surplus or: gets charged, and similar charges push each other. In other words, by moving a charge across a field, it gets less interesting to continue, the field itself gets reduced. The ratio between these is understood as: electrical capacity (char C, measured in Farad).
In formula: dQ = C dV, when I move a charge dQ the field changes dV. When the device that includes the source and the destination of the charge is said to have a large capacity, this means that the displacement of large charges have little effect on the field.

Even when moving the charges hardly effects the field, the charge elements (e.g. electrons) have to bridge the gap between source and destination, collide to each other and to loads of molecules in between, and dissipate some heat. This is understood as electrical resistance (char R, measured in Ohm).
In formula: V = I*R or I=V/R, Ohm’s law. A large resistance is like having air (or less) between two poles of a battery, they are electrically isolated, there is hardly any current and no energy loss. A small resistance is like short-circuiting the battery with a copper wire. Lots of current, and the heat might even melt the wire. As current I = dQ/dt we see that first we had a relationship between ‘field’ V and ‘thing’ Q, and now we’ve got a relationship between V and the first time-derivate of the ‘thing’: dQ/dt.

So the next step is to investigate what happens with that second time-derivative, or: dI/dt. This just means: alternating current. When alternating current is applied onto a coil, it generates an electric field. This is understood as electrical induction, the fundament under dynamos, generators, turbines and the like. Char: F (after Faraday), measured in Henry (both did the discoveries at the same time).
In formula: V = F*dI/dt or dI/dt = V / F, a large induction generates a strong field from the alternating current.

Now, let me bring all the elements together. I’ve got a device with two poles, I apply an alternating voltage onto the poles, and the charges and currents in the device start working in parallel:

Working in parallel implies that I have to add the individual currents, so: (I1+I2+I3) = I total = Voltage / “Impedance” (Impedance is some kind of resistance for alternating currents and voltages, taking capacity and induction into account).

If R very large (isolation), then IMP = iw / (1/F-w2C) and becomes quite large when 1/F-w2C => 0,
that is: w2 => 1/FC. Then the impedance => R again.
This w = sqrt(1/FC) represents the resonance frequency of the system, it behaves at a minimal energy loss.

Now we’ve got the essential formula, let’s apply them on a mechanical system.

Going Mechanical

The mechanical route follows the same approach. The ‘field’ is force (char F, measured in Newton) and the ‘thing’ is displacement (say X, measured in meter). Applying a force of 1 N over 1 m requires 1 J of energy, and applying that force over a route with a speed of 1 m/s requires 1 W of power. Note the similarities with electrical.

A spring pulls and pushes, proportional to its stretch: F = S * X. The stronger the spring, the more force is required to stretch it (with the same amount of displacement). Spring strength does not have a specific name, it’s measured in N/m.

Spring strength is not related to any mass, but when a mass is attached to a string, the force will generate an appropriate acceleration: F = M * a, Newtons Law, where a is d2 X/dt2, the second time derivative of the ‘thing’ we’re considering. M is mass, in kilograms.

So we’ve seen forces proportional to distance X (the spring) and to its second time-derivative acceleration A (gravity like). So all we need to make it like electrical, is a force that is proportional to the first time-derivative of distance, which is: speed, or velocity v. This introduces: damping D as in F = -D*v. The faster you move, the more the force will work against you. Air-resistance is one example of them.

Now we can make the step from electrical to mechanical, just by substituting the equivalent concepts

So electrical capacity C relates to 1/S spring strength

So electrical resistance R relates to 1/D damping

So electrical induction F relates to M mass

And so w = sqrt(S/M) represents the resonance frequency of the system. The resonance becomes noticeable when there is only little damping. Strong springs with little mass with make high frequencies, loosening the springs and/or raising the mass will reduce the resonance frequency. Damping will kill the oscillations and will produce a stable result faster.

Mechanical systems and electrical systems do compare, but to a certain extent. Electrical components can be made quite ideal: capacitors with a good isolation and no leakage (extreme resistance), resistors with hardly capacity or induction by their own, inductors with metal kernels and so on. And those systems are pretty linear over a large range of values, from electron beams in a CRT monitor to outdoor flashes in a thunder storm, the same laws keep applying.

Mechanical components are far less ideal: springs do have mass and damping by themselves, and the stretching is far from linear. When the spring is made of an iron wire coil, there are upper and lower limits to its expansion or compression depending on the length and thickness of the wire used. So in fact the formula should read F = S0 X + S1 X3 + S2 X5 + …

Odd powers only, as all forces work in one direction: against the displacement.
The same holds for damping, as can be found in any aero/fluid-dynamics class or textbook. For low speeds it’s proportional, but at higher speeds the additional terms kick in quickly: F = D0 X + D1 X3 + …

All this means that the math still can be done but that the final resulting formulas become longer and less friendly.

Conclusions

By looking at complex numbers in addition to normal, real numbers, I got tools for expressing fluctuations in a more elegant way. By applying them to electrical circuits with alternating current, I got the formulas for the “impedance” of a system responding to alternating inputs. By applying those formulas to a mechanical context, I got a descriptor for a mechanical system, responding to external forces.

I found that such a system is characterized by

Mass (M), making it harder for a force to accelerate an object

Damping (D), making it easier for a force to reduce an objects speed, and making the object lose energy faster

Spring Strength (S), making it harder for a force to displace an object

Resonance, the tendency to vibrate with a frequency sqrt(S/M). This is reduced by Damping.