Skip to content

Instantly share code, notes, and snippets.

@vurtun
vurtun / _GJK.md
Last active May 1, 2024 22:49
3D Gilbert–Johnson–Keerthi (GJK) distance algorithm

Gilbert–Johnson–Keerthi (GJK) 3D distance algorithm

The Gilbert–Johnson–Keerthi (GJK) distance algorithm is a method of determining the minimum distance between two convex sets. The algorithm's stability, speed which operates in near-constant time, and small storage footprint make it popular for realtime collision detection.

Unlike many other distance algorithms, it has no requirments on geometry data to be stored in any specific format, but instead relies solely on a support function to iteratively generate closer simplices to the correct answer using the Minkowski sum (CSO) of two convex shapes.

@macton
macton / cpuid_features.c
Last active November 5, 2023 02:04
Print cpuid features
// This file: https://gist.github.com/macton/4dd5fec2113be284796e
// See: Intel Intrinsics Guide https://software.intel.com/sites/landingpage/IntrinsicsGuide/
// See: CPUID Explorer http://www.flounder.com/cpuid_explorer1.htm
// See: Playing with cpuid http://newbiz.github.io/cpp/2010/12/20/Playing-with-cpuid.html
// See: MSDN __cpuid, __cpuidex http://msdn.microsoft.com/en-us/library/hskdteyh.aspx
// See: Notes on MMX/SSE and a searchable table of intrinsics. http://www.taffysoft.com/pages/20120418-01.html
// See: AMD CPUID Specification http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/25481.pdf
#if defined(__GNUC__)
#include <stdint.h>