usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< PreviousNext >>

Code to Animate an Image Body through a Sine or Cosine Curve in Visual Basic




How to Simulate Sinusoidal Curves in Visual Basic

Periodic functions produce an infinite order of sinusoidal curves.
The sine function has the general form y = asinθ;
and the cosine function has the general form y = acosθ + c;
where θ is angle in radians and a is an arbitrary constant that heightens the curve.



Code to Animate a Graphic Object through a Periodic Curve in Visual Basic

To make a graphic (dot) travel by the equation of a sine / cosine function, continuously increment θ by some angle interval (in radians), and use the equation to get the corresponding y value; using any c that gives a satisfactory height.

Create a new class;
Call them PanelsPeriodicFunction and PeriodicFunction.
Type out the adjoining VB.Net code for animating an image body through the path of a sine / cosine curve.


Note: To get a cosine curve animation, just replace sin with cos.










<< PreviousNext >>