Monthly Archives: September 2016

Draw an Apollonian gasket in C#

The example Find circles that are tangent to three given circles (Apollonius’ Problem) in C# shows how to find up to eight circles that are tangent to three given circles. This example uses that method to build an Apollonian gasket. … Continue reading

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

Clone lists and arrays of objects in C#

This is the last post I’ll write about clones, at least for a while. Some collection classes can already make clones. For example, an array can clone itself, although the result is always a shallow clone. This example shows how … Continue reading

Posted in algorithms, OOP, syntax | Tagged , , , , , , , , , , , , , | 1 Comment

Clone serializable objects in C#

If a class is serializable, then you can create a deep clone of an object from that class by serializing it and the deserializing it. This example uses the following code to define a generic extension method that clones objects … Continue reading

Posted in algorithms, OOP, syntax | Tagged , , , , , , , , , , , , , | 5 Comments

Find the shortest distance between a point and a line segment in C#

This example treats the segment as parameterized vector where the parameter t varies from 0 to 1. It finds the value of t that minimizes the distance from the point to the line. If t is between 0.0 and 1.0, … Continue reading

Posted in algorithms, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , | 21 Comments

Use MemberwiseClone the ICloneable interface in C#

The example Clone objects in C# explains how to give a class a Clone method that makes copies of its objects. This example makes two changes: it implements the ICloneable interface and it uses MemberwiseClone to simplify the cloning code. … Continue reading

Posted in algorithms, OOP, syntax | Tagged , , , , , , , , , , , , , , , | Leave a comment

Clone objects in C#

A clone of an object is a copy of that object. There are two kinds of clones: shallow and deep. A shallow clone shares all of the same values as the original object, even if some of those values are … Continue reading

Posted in algorithms, OOP, syntax | Tagged , , , , , , , , , , , , | Leave a comment

Convert latitudes and longitudes into distances on the globe in C#

This example shows how you can convert latitudes and longitudes into distances on the globe. The formulas for performing those calculations is interesting but the program is also interesting for the ways it uses LINQ. The program stores information about … Continue reading

Posted in algorithms, LINQ, mathematics | Tagged , , , , , , , , , , , , | 1 Comment

Draw three circles and find their tangent circles in C#

This example is similar to previous one Find circles that are tangent to three given circles (Apollonius’ Problem) in C# except it lets you click and drag to draw the three given circles. It then finds the (up to) 8 … Continue reading

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

Find circles that are tangent to three given circles (Apollonius’ Problem) in C#

Given three objects that can be a point, line, or circle, you can try to draw circles that are tangent to each. The case using three circles is called Apollonius’ Problem. Originally these problems were studied by Euclid (ca. 300 … Continue reading

Posted in algorithms, drawing, graphics, mathematics | Tagged , , , , , , , , , , , , , | 2 Comments

Use steganography to hide one large picture inside another in C#

The example Use steganography to hide one picture inside another in C# explains how you can hide one image inside another. This example uses the same tools to hide a large image inside another large image so you can get … Continue reading

Posted in algorithms, cryptography, graphics, image processing, mathematics | Tagged , , , , , , , , , , , , , , , , , , | Leave a comment