Dangerous Ideas

Today, sine waves, the cool wiggly mathematical lines that are used to represent water and the paths of alien space craft.

Here's a small code snippet to show how to draw them. If, like me, you willfully ignored most of your secondary school math classes - if only they'd told my 13 year old self it was useful for making computer games!

C#:
  1. for (int i = 0; i <100; i++)
  2.             {
  3.                 int x = i;
  4.                 int y = (int) (Math.Sin((double)i * 2.0 * Math.PI / (double)(99)) * 100);
  5.                 graphics.Shapes.DrawPoint(x, y);
  6.             }




Currently browsing

Currently Reading

  • Large-Scale C   Software Design

    Large-Scale C Software Design by John Lakos

  • I Am a Strange Loop

    I Am a Strange Loop by Douglas Hofstadter

  • A Dictionary of Basic Japanese Sentence Patterns (Kodansha Dictionary)

    A Dictionary of Basic Japanese Sentence Patterns (Kodansha Dictionary) by Naoko Chino

  • Japanese Verbs at a Glance (Power Japanese Series) (Kodansha\’s Children\’s Classics)

    Japanese Verbs at a Glance (Power Japanese Series) (Kodansha\’s Children\’s Classics) by Naoko Chino

Goto Library