Quaternions

Quaternions define a 4 dimensional algebra which is particularly useful for dealing with rotations in 3d. They are often used when you might want to produce a smooth rotation by interpolating between two orientations. Common applications are 3d graphics animation (e.g. games or CGI) and robotic kinematics. Quaternions can be thought of as being similar … Read more

Scoped Enumerations

In C++03, enumerations are declared as follows: enum Suit { Hearts, Diamonds, Clubs, Spades }; Suit suit = Hearts; As can be seen, Hearts is in the global namespace. This could give rise to potential name collisions with other enums. Another issue is that it is difficult to find instances of a particular enum via … Read more

Overriding Functions

The C++03 way In C++03, the virtual keyword is used to implement function overloading, as shown in the example below: class Shape { public: virtual bool isCircle() { return false; } }; class Circle : public Shape { virtual bool isCircle() { return true; } }; We can test this code as follows: bool test() … Read more