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







<< PreviousNext >>

Code to Animate an Image Body through a Circle in C#




Using the Equation of a Circle in C#

Circles are represented by the general equation
(x - a)2 + (y - b)2 = r2 ;
where (a, b) is the centre of the circle and r the radius.

Quadratic Points

Solving for y, we have:
(y - b)2 = r2 - (x - a)2
y - b = ±√(r2 - (x - a)2)
y = b ± √(r2 - (x - a)2)



Code to Animate a Body through the Trajectory of a Circle in C#

To make a graphic (dot) travel in a circular path, all we have to do is increment x in the range of a - r ≤ x ≤ a + r; and get the corresponding y value using the equation of the circle.

Create a new class;
Call it CircularPath.
Type out the adjoining C# code for animating an image body through the path of a circle.










<< PreviousNext >>