Grab Bag Release: Math

As you might have noticed, I have slightly changed the order of the development roadmap of my Grab Bag of Useful Stuff: 2D Packing heavily relies on rectangles, and that’s why I decided to implement to the Math classes first. These will come in handy for the second version of the ByChance Framework later, as well.


The Npruehs.GrabBag.Math namespace contains utility classes for many math operations.

Math2 is a useful extension of the .NET System.Math class, providing constants like PiOverTwo, or methods like DegreesToRadians for converting angles and passing them to the .NET trigonometric functions.

John Carmack himself advises to use vector structs instead of fields for x- and y-coordinates, for example. Thus, other parts of the Grab Bag follow that advice, and you can do so as well. The vector structs are immutable and feature a lot of convenient operator overloads.

John Carmack @ID_AA_Carmack 9:15 PM – 5 Mar 13

I advocate the use of an idVec2i type for all two integer element tasks over discrete x/y, width/height, etc. A lot of code is improved.

Additionally, there are geometry classes for rectangles and boxes for the same reason.

Author: npruehs

Nick Pruehs is a Co-Founder of Slash Games, Hamburg. In 2009, he graduated as “Best Bachelor” in computer science at Kiel University. Two years later Nick finished his master’s degree in “Sound, Vision, Games” at Hamburg University of Applied Sciences, becoming the Lead Programmer of Daedalic Entertainment shortly after.

Questions? Comments? Suggestions? Your turn! :)