Biking 101: Turning corners

Believe it or not, riding a motorbike and knowing how one turns are two different things.  Professional rider training organisations will introduce you to the concept of “counter-steering” and some may even attempt to explain how this phenomenon works, but, you don’t have to understand it to ride a bike.  Here’s the briefest summary I can give you on what counter-steering is:

If you want to turn left, you turn the front wheel to the right. 
If you want to turn right, you turn the front wheel to the left.

After you’ve read that, I think you’ll understand why the technique is called “counter-steering”.  What’s more is, it actually works!  Here’s my attempt at something between a layman’s explanation and the physics nerd’s explanation.  The explanation given is based off my understanding and what I’ve observed first hand.  I promise I won’t go close to using mathematics in my explanation!

The gyroscopic effect of the turning wheels is what holds a motorcycle up once it is moving at any sort of speed.  (Say around 20kph / 12mph).  The two wheels on the bike have different roles to play.  If we discount the effect of suspension travel, the rear wheel remains with its axis fixed relative to the rest of the motorcycle, whilst the front wheel allows its axis to pivot left and right (when viewed from the rider’s perspective). 

The rear wheel is responsible for keeping the motorcycle moving in the same direction of travel.  The front wheel is responsible for changing this direction of travel.

Lets look at the rear wheel effect first:
If you spin a gyroscope where the top of the wheel is not centred above the bottom, it will maintain this angle, providing the gyroscope does not lose momentum.  Given the freedom of being able to move, it will circle in the direction matching the side the top leans to.  Therefore, once a motorcycle is leaning, it will move in an arc in the direction of the lean. 

Figure 1: Trajectory of leaning wheel 

Once the rear wheel is spinning with a fair degree of velocity, the weight of the rider and motorcycle become insignificant compared to the gyroscopic effect of the rear wheel.  Although you can use your body-weight to lean the motorcycle into a corner, it’s a slow and arduous process unless you can influence the direction the front wheel is pointing.

Here’s where the front wheel comes in:
Forcefully altering a gyroscope’s orientation will cause it to behave in strange ways.  This is best demonstrated with a loose pushbike wheel.  Spin the wheel up whilst holding the ends of the axle. 

A badly drawn arrow indicating a spinning wheel

Push the left end of the axle “forward” and pull the right end toward you.

Oh look, now there are dodgy green arrows as well! 

You will feel the wheel “react” to this movement and the wheel will lean to the left. 

Dodgy red arrow removed to make blue arrow easier to spot

The easiest way to return the wheel to the vertical plane, is to reverse the action you just did.  That is: pull the left hand toward you and push away with the right.

Putting it all together:
With our increased understanding of what is going on, we’re ready to “hit the road”.  (That should be taken as a “figure of speech”, rather than a “literal interpretation”)

  1. Travelling forward on the bike we push the left handlebar away from us.  As explained above, this will cause the front wheel to lean to the left.  The rest of the motorcycle will follow, resulting in both wheels now leaning to the left.
  2. We stop pushing the left handlebar, allowing it to resume a “neutral” position.  It requires some force on our part to remain at this current lean angle, as the gyroscopic effect of the front wheel will now make it “want to” turn in more.
  3. Because the wheels are leaning, the bike travels in an arc.
  4. Once the joy of turning left has worn thin, we need to stand the bike back up.  So, we reverse the process and push the right handlebar forward.

And that’s the simplified version of turning corners on a bike!  I will leave “turning right” as “an exercise for the reader”. 

Some points in closing:

  • I’ve heard it claimed that the Wright brothers (as in the bicycle makers who forgot that push-bikes weren’t meant to fly) noted that you counter-steer bikes.  Later observations (such as “look, my brother is flying”) seem to occupy most text that you see written on the duo.
  • Whilst counter-steering works for push-bikes, the relative weight of the rider compared with the bike means it is much harder to observe the effect.  Body weight / balance play a bigger role.
  • Rider training will teach you to push  the bars, not pull  on the opposite bar.*  I believe this is taught to stop you gripping the bars too tightly.  A loose relaxed grip with your hands is a safer way to ride.
  • Throttle control also plays a large part to how well you can ride around a corner, but that is a story for another day. 

* Personally, I find it easier to feel the gyroscopic effect of the front wheel by pulling on the bars, probably because my arms are tense when doing so.  From changing between the two techniques, I find pushing the bars easier to control.

An introduction to C# iterators

I want to write a blog article on the inner-workings of iterators. If you’re writing C# code, chances are you’ve consumed an iterator with the foreach keyword. However, if you’re not familiar with writing iterators, here’s an introduction on writing them.

The first example is of a simple counter iterator. Here’s the code in its entirety:

Source code
This produces fairly predictable results:

1 2 3 4 5 6 7 8 9 10
Press any key to continue…

If you’re new to this, all you really need to notice is the yield return statement. You can think of this as a normal return keyword, except it leaves the function “hanging”. Next time the function is used, it will resume from this point – counter will be incremented and the while loop continues. Under the hood, it’s not exactly like that – but it’s a useful approximation of what is going on. You will notice that the return type for the function is actually IEnumerable<int>, however, you need to return the primitive type specified within the angled brackets <> when using the yield return keyword.

One of the classic computer-science problems to solve is reporting prime-numbers. Here’s a version that uses an iterator to report all primes up to a number specified:

Prime number generator source code

Which produces the output:

1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Press any key to continue…

The mathematicians may want to argue over whether or not 1 and 2 are actual prime numbers, but doing so misses the point of this post! Looking at the IsPrime function, you’ll notice a for loop and think: “Hey! Our counter iteration from earlier would do the same thing!” . So in the next version, that’s exactly what I’ve done!

Sexier Prime number generator

I have one final “optimisation” to make. I use the term loosely, because I have done no performance testing to vouch that it makes the program any more optimal… It’s really done to show that you can combine recursion and iterators. To test for a prime number, you need to see if a number has any divisors other than 1 and itself. Furthermore, if you can’t divide a number (y)evenly by a different number (x), then any multiple of x will also not be a divisor of y. Therefore, when testing for prime numbers, there’s no point testing divisors unless they are prime numbers themselves.

Have a look at our IsPrime function again. Rather than using the counter iterator to go through every possible denominator, we can use our prime iterator to only go through denominators that are prime numbers! We do have to tweak it a little, as “1” becomes a special case… (Can anyone say “endless loop”?) Here’s the final version:

Sexiest prime number generator

The point is, iterators are really cool. (Well, in a nerdy sense at least) If you’re not using them in your C# coding, then you should be! I guess it depends on how often you write code that conforms to an iterator type construct, but there’s a lot of scope there, so get thinkin’! I don’t think C# iterators can quite match the power of python’s generators, but I’m not a python coder… Python allows you to append results to the set of results the generator “yields”. There’s a good demonstration of prime number producers written in python on Wikipedia demonstrating this concept.

Very interesting, but I don’t agree with you…

My blog is very much in its infancy. As such I expect the readership to be small in number. At the moment, my main aim is to build content. – Content that people will find interesting and worth their time.

If this blog becomes “successful”, these early articles will help piece together the history of the site and fill in that extra time when people come to the site and find the newest article too short to fill in a lunchtime at work. :-)

Around mid-December, I got a real shock when I received a comment on one of the articles I’d written. The IP-address was based in Canada and as far as I knew, it wasn’t from anyone I knew personally. The comment was light-on, but seemed in context enough, so I approved Idetrorce and their “Very interesting, but I don’t agree with you” comment. Soon after, it became apparent that my readership had not in fact doubled, but I’d been conned by a spam-bot.

Since then there has been much speculation over who Idetrorce is and what their motives are. Hank “The Ozz” Osborne of www.hoei.com has a sinister thought:

In my humble opinion, this is a pre-attack campaign for a bigger spam campaign that will come in the next few weeks. The comment above would be okay on most blog posts since it is not trying to link people back to a product of service and it is just a polite disagreement

If a blogger does not block the email address and user name associated with this comment, then they could be opening themselves up to something much bigger coming down the pipe.

I hope he’s wrong, but it does seem a fairly logical conclusion to draw, given the number of people who have opinions not matching idetrorce’s. In the month or so since idetrorce started disagreeing with bloggers world-wide, he (or she) has managed to attract growing amounts of speculation – people now wondering who idetrorce is… There are now some 431,000 hits on Google.

From the web-browsing I have done, it is apparent that this spam-bot exists in multiple places leading me to the conclusion that it is viral, and not initiated by a single entity with too much bandwidth.

One of the hits now showing up on Google is a link to a user account on “Snowboard mag“. One of the interesting points with this user-account is that it has been active for the same amount of time as these comments have been appearing on people’s blogs. As other bloggers/commenters have pointed out on this one, “This may just be a coincidence”. I’ll let others draw their own conclusions.

“Everybody’s lost, but me!”

I think I need a GPS…  I was leading some friends on a ride today.  I had been keen to go for an “exploratory ride” by myself, to familiarise myself with the roads around the Glasshouse Mountains.  There are a lot of forestry roads, some sealed, and a lot dirt.  I didn’t promise anyone an exciting ride, as I knew a lot of the terrain was flat and bordered pine plantations.  Those two combinations tend to add up to straight, dull roads… 

I had spent some time scouring Google Maps and Google Earth, attempting to work out how to stay on the bitumen and how to find some windy bits.  But my plans still quickly unravelled.  My ancient book of maps (circa 1992) has always proved to be hopeless and inaccurate once you get down to these sorts of roads.  For the sake of anyone outside of Australia reading this, allow me to paint you a picture:

We are not talking “out back” here…  The roads I was on today are less than an hour’s drive from Brisbane (population approx 1.5 million people)  As I mentioned, these roads traverse through pine plantations as well as other farms (namely pineapple)  But, they don’t get much traffic.  Side roads don’t tend to be terribly well signed and I don’t recall passing a car going in the opposite direction for the period of about 20 minutes as we rode along Twin View Road and others.  – So, if you know where you’re going, you will be fine!

As an exercise for the reader, follow along my intended route on Google Earth or, directly in the Web browser if you’d prefer:

  • Head roughly NNW along Old Gympie Roadout of Caboolture.
  • Turn left onto Twin View Road. – I’d already got lost before getting this far!  The main road deviates to the right and becomes Smith(s) Rd.  This takes you back into Elimbah, but, from my map study, I knew I could rejoin Twin View Rd there… Until I’d arrived in Elimbah, I’d no idea I’d left Old Gympie Road!
  • Stay on Twin View Rd as it deviates from Scurr Rd.  – I missed this one too, and gave up at this point.  Following “the main road” takes you along Scurr and then Newlands Road back to Wamuran.  At least I then knew where I was, so stuck to tried and tested roads…
  • If I’d still been on-track…  Turn right onto Raaen Rd.
  • This road merges with the Glasshouse-Woodford Rd.
  • Take that road back to Old Gympie Road, turn left and head for Beerwah. 

The more I look at that with Google Earth, the more convinced I am that we would of traversed lots of dirt roads.  If you use Google Earth, with the “roads” option on, you see a fair degree of approximation between reality and the way the roads look in real life:  Going back to my first missed turn you will see that the “roads” indicated a straight path.  The maps on whereis.com(Search for “Smith Road | Elimbah | Qld”) has a much better indicator that you will need to turn left, to stay on Old Gympie Rd.  Search again in Street Directory and you get even more detail!  I guess “local knowledge” counts for something.

My point is, not all mapping tools are created equal.  As far as I am concerned, a GPS unit is only as good as the maps you get in it.  All the fancy features in the world aren’t going to do you any good, if it can’t pinpoint you and know when you will need to veer down the side road to stay on course.  (Of course, you would expect any GPS to tell you to do a U turn after you failed to correctly navigate the last intersection but that’s still only secondary to getting it right in the first place)   

Ride safely

2007 was a a bad year for motorcycle related deaths on Queensland roads.  It truly is a tragedy that anyone dies in a vehicle accident and if you’ve been personally affected by the loss of a loved one I extend my condolences to you.

I used to summarise motorcycling as “Not dangerous providing you don’t hit something or fall off” and I still believe that thought has merit.  In the event of an accident, your chances of being seriously injured or killed are greatly exaggerated on a motorcycle (when compared to a car) and if you’re riding but not admitting this to yourself, you are probably doing yourself an injustice.  It’s this realisation that can help motivate you to go to the extra effort to keep yourself safe. 

I’ve been riding motorbikes on the road for around fifteen years now – and have yet to have an accident.  I refuse to be superstitious about this (by adding a “touch wood” style comment) – and I still remind myself that it’s not beyond me to have an accident.  Do I have the definitive secret to riding safely on the road?  I can only wish!  Ask enough riders how they keep safe and you will probably end up with a conflicting set of answers.  But I refuse to believe that “luck” needs to play any part of it.

I’ve raced (and crashed) motorcycles on a race-track.  To quote a fellow racer “I never set the world on fire” in terms of my on-track performances, but it did teach me a few lessons.

  1. Motorcycles are harder to crash that you might imagine.  Providing you’re getting gyroscopic effect from wheels turning they are incredibly stable.  In the event that you lock a wheel on the motorbike, the quicker you can get it turning again, the quicker stability returns to the bike.
  2. The biggest issue working against you keeping the motorbike upright is usually yourself…  “Panic” suppresses your ability to deal with an emergency situation.  If you can recognise the on-set of it, you may have a fighting chance of dismissing the panic and saving the situation.

On the road, these points still apply, but can be rather academic if your scenario includes other vehicles.  Road position / covering brake levers / situational awareness and many other factors all help improve your chances but these can best be summarised as “Concentration on the job at hand”.   Don’t ever allow yourself to think that it couldn’t happen to you…  Ride safely and enjoy the sense of freedom only motorcycling can offer.