Let's talk about piiiii!
This post will explain what on earth Pi even is.
This guy:
π
It's the Greek letter 'pi', that's how it's pronounced. You might see it written as 'Pi' or as 'π' but it's the same thing. It's used in mathematics to talk about a very special number. A very special ratio. I can't overstate just how fundamental the number Pi is to mathematics. It shows up as the answer to so many problems in the natural world. It's freaky. Like there's logic to the fundamental structure to the universe. But not an order that could pick a more convenient number, because the magical number I'm talking about - the number that Pi refers to, is this number:
3.141592653589793238462643...
The reason it trails off like that is because it's what's called an irrational number. You don't gotta remember that, it's just a fancy way of saying it's a number whose decimal places go on forever without a pattern ever emerging. It's crazy, I know. Numbers are weird.
So Pi is usually talked about in terms of just its first two or three decimal places:
3.14
Alright, so Pi is approximately 3.14. What a strange looking number. What's so special about it?
Let's talk about circles.
You like circles? I do. All the best food is circular. Pizza, takoyaki, Wagonwheels, cake, other pastry-shelled dishes whose names just aren't coming to me right now...
Let's talk about circles.
You like circles? I do. All the best food is circular. Pizza, takoyaki, Wagonwheels, cake, other pastry-shelled dishes whose names just aren't coming to me right now...
So suppose you want to measure a circle. There are a few measurements you can take:
Radius:
The distance in a straight line from the dead-centre of a circle to any point on its edge. Any point! It's all the same. That's just how circles work. The centre is the same distance away from any point on the edge.
Diameter:
The diameter is the distance in a straight line from one point on the edge of a circle, right through the middle and out the other side.
It has to go through the centre. None of this business:
As you might have noticed, for any circle, the diameter is just the radius times two. So that's handy.
Circumference:
Alright, now we're getting to it. The circumference is the distance all the way around the edge of the circle. If you walked along the edge of the circle precisely one time, the distance you'd have walked would be the circumference.
Why the circumference is a little trickier is because it's not a straight line. So how do you measure it? If you had a circular object, you could wrap a tape measure around it. That would probably do you for most around-the-house practical applications of the circumference. But in areas like mathematics, physics, engineering, and indeed rigging, we need a more precised, more reliable, not to mention quicker method.
That's where Pi comes in.
Pi, simply put, is the ratio of a circle's circumference to its diameter.
Dafuq? What does that mean?
It means for any circle - (lemme say that again. Any circle!) - the circumference is equal to the diameter multiplied by Pi - that is to say, multiplied by 3.1415926535897(and on and on and on).
Dafuq? What does that mean?
It means for any circle - (lemme say that again. Any circle!) - the circumference is equal to the diameter multiplied by Pi - that is to say, multiplied by 3.1415926535897(and on and on and on).
So if you have a circle whose circumference you need to know, it's a lot easier to measure the diameter, since it's a straight line, and multiply it by Pi to get the circumference.
To try and visualise that, if you took a length of tape measure that when pulled taut was the exact length of a circle's diameter, if you then got a bunch of duplicate lengths of tape measure with all of that same length and put them end to end and wrapped them around the edge of circle, you would get through about 3.14 of them before wrapping around the circle once.
You may be wondering what it even means to multiply by a number that has infinite decimal places. That is an odd idea to wrap once's head around. Since Pi's has infinite decimal places, that means it offers infinite precision... assuming we have infinite capacity and time to measure. But we don't, we gotta get this rig done by Thursday, sucka! So in any situation where we need to measure a circle's circumference, we need to decide how many decimal places to account for, and in doing so deciding how precise we need the measurement to be.
If we multiply a circle's diameter by 3.14, in most cases that would give us an accurate enough result. But if you find that it's not, like there's some discrepancy in your rig that is just a liiiittle off and is noticeable to your audience, then maybe you need to add an extra digit or two into your multiplication.
Physicists doing crazy science involving really really big stuff like planets, or really really small stuff like particles would probably make a point of using a looooooot of digits, because they need crazy precise measurements.
A common stress test for really powerful computers is to have it calculate Pi to the shitzillionth decimal place.
But in rigging, I doubt you'll ever need to go higher than maybe three decimal places. Happy days.
A common stress test for really powerful computers is to have it calculate Pi to the shitzillionth decimal place.
But in rigging, I doubt you'll ever need to go higher than maybe three decimal places. Happy days.
You may wonder what to do if the circle isn't perfectly circular. Will this still work then?
No. If the circle isn't a perfect circle then as far as mathematics is concerned it doesn't even qualify as a circle. No ovaloids allowed in the Pi club!
No. If the circle isn't a perfect circle then as far as mathematics is concerned it doesn't even qualify as a circle. No ovaloids allowed in the Pi club!
In Maya
Alright so... wow, numbers are... sure something. Let's have an example of how Pi is useful to us.
Say in your Maya scene, you've got a car, or a wagon, or something with wheels. As it travels along the ground, obviously a wheel needs to turn. It sure can be a pain to hand animate the wheel turning. Getting it turning at just the right speed so it looks like there is actually a relationship between the wheel and the ground. You don't want it turning to slow or too fast. That just doesn't look right.
Well check it out. Take the distance the wheel travels along the ground, divide it by the circumference of wheel to get the number of times the wheel should complete a revolution for the animation to look right.
But to do that we need to know what the wheel's circumference is. How do we do that, with Pi!
But to do that we need to know what the wheel's circumference is. How do we do that, with Pi!
Let's get our hands dirty and actually do that with Maya's tools.
Here's my wheel.
I want to measure the diameter.
If you're observant, you might have notices that since the radius is half of the diameter, we could also get the circumference by multiplying radius by Pi times 2.
That's a handy observations so let me restate it:
If you're observant, you might have notices that since the radius is half of the diameter, we could also get the circumference by multiplying radius by Pi times 2.
That's a handy observations so let me restate it:
circumference = diameter * π = radius * π * 2
It's for this reason people often talk about "Two Pi", simply meaning Pi times 2. In recent years, people have also started using the Greek letter τ ('Tau') to mean 2 times Pi. (People like me. I encourage it. Team Tau for life!) Because many people find it handier to derive the circumference from the radius, instead of the diameter. It's the same business either way. Pick your poison.
So I'll place a locator at dead centre of the wheel, and another locator at the edge the wheel.
This wheel's geometry is going to be smoothed at render time, so that smoothing will displace the vertices ever so slightly. So when placing that second locator along the edge I want to make sure I'm matching to where the edge will be once it's smoothed, so I'll make sure hit the 3 key to get a smooth mesh preview.
This wheel's geometry is going to be smoothed at render time, so that smoothing will displace the vertices ever so slightly. So when placing that second locator along the edge I want to make sure I'm matching to where the edge will be once it's smoothed, so I'll make sure hit the 3 key to get a smooth mesh preview.
I could get the distance between these two locators a few different ways. I'm going to a distanceBetween node.
Into it I simply plug the worldMatrix outputs from both locators, that carries information regarding where the locators are in world space.
Into it I simply plug the worldMatrix outputs from both locators, that carries information regarding where the locators are in world space.
As a bonus, I'm going to parent both locators to the wheel (you rarely parent stuff directly to the geo, you'd more likely parent it to the joint to which the wheel is skinned, or to the control that drives the wheel, but whatever, I'm keeping it simple)
By parenting these locators to the wheel, I can freely scale the wheel up and down and the locators will still be at the centre and edge of the wheel respectively, so the measurement given by the distanceBetween node will remain accurate regardless of it wheel's scale.
By parenting these locators to the wheel, I can freely scale the wheel up and down and the locators will still be at the centre and edge of the wheel respectively, so the measurement given by the distanceBetween node will remain accurate regardless of it wheel's scale.
So We've got the radius now. Let's perform a simple multiplication by Pi all up on that shit.
I create a node to do the multiplication, in my case a multDoubleLinear node, I feed the distanceBetween node's distance output into input1, and in input2 I type 3.141.
I create a node to do the multiplication, in my case a multDoubleLinear node, I feed the distanceBetween node's distance output into input1, and in input2 I type 3.141.
And like magic, the output of that multDoubleLinear node is the circumference of the wheel!
Now regardless of how far the wheel is traveling I can simply take the output of the keyframe node driving that translation and divide it by the multDoubleLinear node's output (using a second multDoubleLinearNode), and the resulting number will be the amount the wheel should be turned at at any given point in the animation.
When you plug the result into the wheel's rotate channel (in my case, Rotate Y) a unitConversion node will be created. In my case, the wheel was turning the wrong way, so I just went into the unitConversion node, got its conversionFactor attribute which was setup automatically as 0.017 and flipped it to -0.017.







No comments:
Post a Comment