My Circle Library

Example Circle ApplicationComputers have always done rectangles and squares, but often times circle logic is needed. I found that I was repeatedly writing the same set of methods to do simple things like finding distance between two points, or placing a point a particular distance away from another point on a given angle. As much as I love Trig, I haven't had a class in Trig for over seven years. So I sat down and wrote it all up just once so I never would have to again.

Although there's no necessity to draw the circles you may use, they can abstractly represent a proximity around another visual object. With the Overlap and Contains methods, you can quickly tell if two entities are within a particular distance of eachother. With the GetPointAtAngle methods you can get a point at a given angle from the center that lies on the edge of the circle. The last method is the MinimalEnclosingCircle method, as its name suggests it returns a Circle object that is the absolute smallest that will contain the two circles given to the method.

Like the Rectangle and Point objects already in .NET, I wrote this to have Circle and CircleF variations. This isn't a huge breakthrough project of mine, just something I'm tired of rewriting over and over again. If you want it, you can get the source code here.

blog comments powered by Disqus