Sine Linguistic Communication Lesson, Purpose 1

I've had this thought ruminating inwards my heed for roughly fourth dimension now. Math is a big part of graphics evolution in addition to I'm sure no expert, but I wanted to present off roughly cool things that tin last done amongst sine waves. This part introduces the concept in addition to shows roughly fun demo programs you lot tin play with; part 2 volition delve into the inner workings of the demos, which accept been adapted from Frank Luna's Introduction to 3D Game Programming amongst DirectX 9.0c: H5N1 Shader Approach.

You may recall from your high schoolhouse Trigonometry course of teaching (don't worry if not, it was a long fourth dimension agone for me too!) those 2 periodic functions, sine (pronounced "sign") in addition to cosine ("co-sign"). They're essentially the same part in addition to you lot could map ane to the other amongst a slight shift. Cosine has roughly unique applications of its own, such equally determining calorie-free intensity based on viewing angle, but the demos below volition focus primarily on sine waves.


Notice a few interesting properties from the graph above. One is that a sine moving ridge repeats itself every 2π (π ≈ 3.14159) or 360 degrees along the X-axis. Another is that it oscillates betwixt the Y values -1 in addition to 1. We write the part y = sin(x) to betoken the Y value equally a part of X; encounter from the graph higher upward that Y = 0 when X is whatever multiple of π in addition to Y is either 1 or -1 (the peaks in addition to valleys) when X is an strange multiple of π/2.

Point Light Demo - Download Program!

This demo shows how sine waves tin last used to animate a calorie-free source. Use the specified keys to combine waves, creating a multifariousness of unique horizontal in addition to vertical motility paths.

Before learning this elegant method, my approach to animating an object that sways dorsum in addition to forth, or moves repeatedly upward in addition to downward along a pole, was to utilization code similar this inwards my update loop:
     static bool moveUp = true;     if (moveUp)      { if (shipPos.y < 100) shipPos.y += value; else moveUp = false; }     else      { if (shipPos.y > -100) shipPos.y -= value; else moveUp = true; } 
With sine waves, this code reduces merely to shipPos.y = 100 * sin(x)! Notice that I multiplied past times 100 to acquire the desired hit instead of the criterion oscillation from -1 to 1.

Ocean Waves Demo - Download Program!

This demo illustrates the effects of adding sine waves in addition to 2 dissimilar moving ridge types, round out in addition to directional. Use the specified keys to play amongst parameters in addition to modify the moving ridge patterns.

As amongst the Point Light demo, you lot volition quest to accept DirectX (from Windows Update) installed inwards club to run the program.

These are exactly a span applications of the sine function. Because of its periodic repetition, it could accept many potential uses; roughly beau GCG forum members cited their implementations of a 3D carousel in addition to a wavy spaceship flying path equally additional examples.

I promise you lot relish the demo programs of this post, though I acknowledge I nonetheless quest to larn improve methods of input handling. Part 2 volition depict moving ridge alterations, based on the Ocean Waves demo, inwards greater detail. Until then, experience gratis to permit us know: What's the coolest matter you've done amongst sine/cosine waves?

Subscribe to receive free email updates:

0 Response to "Sine Linguistic Communication Lesson, Purpose 1"

Post a Comment