Calculating a LookAt matrix

Note the example given is a left-handed, row major matrix. So the operation is: Translate to the origin first (move by –eye), then rotate so that the vector from eye to At lines up with +z: Basically you get the same result if you pre-multiply the rotation matrix by a translation –eye: [ 1 0 … Read more

How to test randomness (case in point – Shuffling)

Statistics. The de facto standard for testing RNGs is the Diehard suite (originally available at http://stat.fsu.edu/pub/diehard). Alternatively, the Ent program provides tests that are simpler to interpret but less comprehensive. As for shuffling algorithms, use a well-known algorithm such as Fisher-Yates (a.k.a “Knuth Shuffle”). The shuffle will be uniformly random so long as the underlying … Read more

Calculate the center point of multiple latitude/longitude coordinate pairs

Thanks! Here is a C# version of OP’s solutions using degrees. It utilises the System.Device.Location.GeoCoordinate class public static GeoCoordinate GetCentralGeoCoordinate( IList<GeoCoordinate> geoCoordinates) { if (geoCoordinates.Count == 1) { return geoCoordinates.Single(); } double x = 0; double y = 0; double z = 0; foreach (var geoCoordinate in geoCoordinates) { var latitude = geoCoordinate.Latitude * Math.PI … Read more

Nth Combination

Note you can generate the sequence by recursively generating all combinations with the first element, then all combinations without. In both recursive cases, you drop the first element to get all combinations from n-1 elements. In Python: def combination(l, r): if r == 0: yield [] elif len(l) == r: yield l else: for c … Read more