Convert Quaternion rotation to rotation matrix?

The following code is based on a quaternion (qw, qx, qy, qz), where the order is based on the Boost quaternions: boost::math::quaternion<float> quaternion; float qw = quaternion.R_component_1(); float qx = quaternion.R_component_2(); float qy = quaternion.R_component_3(); float qz = quaternion.R_component_4(); First you have to normalize the quaternion: const float n = 1.0f/sqrt(qx*qx+qy*qy+qz*qz+qw*qw); qx *= n; qy … Read more

Polygon Triangulation with Holes

To give you some more choices of libraries out there: Polyboolean. I never tried this one, but it looks promising: http://www.complex-a5.ru/polyboolean/index.html General Polygon Clipper. This one works very well in practice and does triangulation as well as clipping and holes holes: http://www.cs.man.ac.uk/~toby/alan/software/ My personal recommendation: Use the tesselation from the GLU (OpenGL Utility Library). The … Read more

How to apply a fade transition effect to Images using a Timer?

There are some problem to fix here: → fadeTimer.Interval = 10;: You’re (possibly) using the wrong Timer: the System.Timers.Timer‘s Elapsed is raised in a ThreadPool Thread. Unless you have set the SynchronizingObject to a Control object, which is then used to marshal the handler calls, referencing a Control in the handler will cause trouble (cross-thread … Read more

IPhone Text Glow Effect

As of 3.2 you there is direct support for shadows in the SDK. label.layer.shadowColor = [label.textColor CGColor]; label.layer.shadowOffset = CGSizeMake(0.0, 0.0); Play with the parameters: label.layer.shadowRadius = 3.0; label.layer.shadowOpacity = 0.5; And to avoid shadow being clipped by the label bouds: label.layer.masksToBounds = NO; Don’t forget to #include <Quartzcore/Quartzcore.h> and link against the QuartzCore or … Read more