Tag Archives: mathematics

Animate rainbow colors in C#

The example Map numeric values to and from colors in a color gradient in C# draws a color gradient that uses rainbow colors. This example animates that one. When you click on the color gradient, the following code starts or … Continue reading

Posted in algorithms, animation, graphics, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment

Animate exploding 3-dimensional pie slices in C#

The example Draw 3-dimensional pie slices in C# shows how to highlight one or more 3-D pie slices by “exploding” them. This example draws even more attention to the exploded pie slices by animating their explosion. The program controls the … Continue reading

Posted in algorithms, animation, graphics, mathematics, multimedia | Tagged , , , , , , , , , , , , , , , , , , | Leave a comment

Calculate where a line segment and an ellipse intersect in C#

Finding the intersection between a line segment and an ellipse requires a lot of mathematics. It’s not particularly hard mathematics, but if you’d rather skip it, you can use the following links to jump to the other parts of this … Continue reading

Posted in algorithms, drawing, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , | 5 Comments

Produce a repeatable series of “random” numbers in C#

The Random class can generate a series of pseudo-random numbers. They’re called “pseudo-random” rather than “random” because the numbers are generated by a mathematical algorithm rather than by some completely unpredictable process such as observing a source of radioactive decay … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , , | Leave a comment

Book Review: The Manga Guide to Linear Algebra

(Occasionally I post reviews of book that I think may interest programmers, in this case admittedly only those with a mathematical inclination.) The Manga Guide to Linear Algebra   $24.95, 264 pages, 2012 By Shin Takahashi No Starch Press ISBN … Continue reading

Posted in books, mathematics | Tagged , , , , , , , , | Leave a comment

Make extension methods to generate random double values in C#

This example adds extension methods to the Random class to generate double values within a specified range. The Random class provides methods for generating pseudo-random numbers. The Next method has three overloaded versions that produce a non-negative integer, an integer … Continue reading

Posted in extension methods, mathematics | Tagged , , , , , , , , , , | 1 Comment

Calculate the present value of a future amount of money in C#

This example shows how to calculate the present value of a future amount of money. Suppose you want a certain amount of money in a given number of years and you know you can realize a specific interest rate (compounded … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | Leave a comment

Compare the performance of simple arithmetic operations in C#

I saw a post the other day that said division was the slowest arithmetic operation so I wrote this example to see exactly how the performance of multiplication, division, addition, and subtraction differ with floating point numbers. When you click … Continue reading

Posted in mathematics, performance | Tagged , , , , , , , , , , , | 1 Comment

Make a 3D globe in WPF and C#

This example shows how you can draw a 3D globe. More generally it shows how you can make a three-dimensional textured sphere in WPF. The example Draw smooth spheres using WPF and C# shows how to make smooth colored spheres. … Continue reading

Posted in algorithms, drawing, geometry, graphics, mathematics, wpf, XAML | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Graph event probabilities in C#

The example Calculate the probability of an event occurring in a given number of trials in C# shows how to calculate event probabilities. This example graphs the results. You can use the example to get some feel for how the … Continue reading

Posted in drawing, graphics, mathematics | Tagged , , , , , , , , , , | Leave a comment