百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

libccd

> 编程语言
开源

用于检测两个凸形体之间的碰撞的库

645 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于检测两个凸形体之间的碰撞的库

libccd

libccd is library for a collision detection between two convex shapes. libccd implements variation on Gilbert–Johnson–Keerthi algorithm plus Expand Polytope Algorithm (EPA) and also implements algorithm Minkowski Portal Refinement (MPR, a.k.a. XenoCollide) as described in Game Programming Gems 7.

libccd is the only available open source library of my knowledge that include MPR algorithm working in 3-D space. However, there is a library called mpr2d, implemented in D programming language, that works in 2-D space.

libccd is currently part of:

  1. ODE library (see ODE's ./configure --help how to enable it),
  2. FCL library from Willow Garage,
  3. Bullet3 library (https://github.com/bulletphysics/bullet3).

For implementation details on GJK algorithm, see http://www.win.tue.nl/~gino/solid/jgt98convex.pdf.

Dependencies

This library is currently based only on standard libraries. The only exception are testsuites that are built on top of CU (https://github.com/danfis/cu) library licensed under LGPL, however only testing depends on it and libccd library itself can be distributed without it.

License

libccd is licensed under OSI-approved 3-clause BSD License, text of license is distributed along with source code in BSD-LICENSE file. Each file should include license notice, the rest should be considered as licensed under 3-clause BSD License.

Compile And Install

libccd contains several mechanisms for compiling and installing. Using a simple Makefile, using autotools, and using CMake.

1. Using Makefile

Directory src/ contains Makefile that should contain everything needed for compilation and installation:

  $ cd src/
  $ make
  $ make install

Library libccd is by default compiled in double precision of floating point numbers - you can change this by options USE_SINGLE/USE_DOUBLE, i.e.:

  $ make USE_SINGLE=yes

will compile library in single precision.

Installation directory can be changed by options PREFIX, INCLUDEDIR and LIBDIR. For more info type 'make help'.

2. Using Autotools

libccd also contains support for autotools: Generate configure script etc.:

  $ ./bootstrap

Create new build/ directory:

  $ mkdir build && cd build

Run configure script:

  $ ../configure

Run make and make install:

  $ make && make install

configure script can change the way libccd is compiled and installed, most significant option is --enable-double-precision which enables double precision (single is default in this case).

3. Using CMake

To build using make:

  $ mkdir build && cd build
  $ cmake -G "Unix Makefiles" ..
  $ make && make install

To build using ninja:

  $ mkdir build && cd build
  $ cmake -G Ninja ..
  $ ninja && ninja install

Other build tools may be using by specifying a different generator. For example:

  $ cmake -G Xcode ..
  > cmake -G "Visual Studio 14 2015" ..

To compile using double precision, set the ENABLE_DOUBLE_PRECISION option:

  $ mkdir build && cd build
  $ cmake -G "Unix Makefiles" -DENABLE_DOUBLE_PRECISION=ON ..
  $ make && make install

To build libccd as a shared library, set the BUILD_SHARED_LIBS option:

  $ mkdir build && cd build
  $ cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON ..
  $ make && make install

To build the test suite, set the BUILD_TESTING option:

  $ mkdir build && cd build
  $ cmake -G "Unix Makefiles" -DBUILD_TESTING=ON ..
  $ make && make test

The installation directory may be changed using the CMAKE_INSTALL_PREFIX variable:

  $ mkdir build && cd build
  $ cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/path/to/install ..
  $ make && make install

GJK - Intersection Test

This section describes how to use libccd for testing if two convex objects intersects (i.e., 'yes/no' test) using Gilbert-Johnson-Keerthi (GJK) algorithm.

Procedure is very simple (and is similar for usages of library):

  1. Include ** file.
  2. Implement support function for specific shapes. Support function is function that returns furthest point from object (shape) in specified direction.
  3. Set up ccd_t structure.
  4. Run ccdGJKIntersect() function on desired objects.

Here is skeleton of simple program:

…

GJK + EPA - Penetration Of Two Objects

If you want to obtain also penetration info about two intersection objects ccdGJKPenetration() function can be used.

Procedure is almost same as for previous case:

…

MPR - Intersection Test

libccd also provides MPR - Minkowski Portal Refinement algorithm that can be used for testing if two objects intersects.

Procedure is similar to the one used for GJK algorithm. Support function is same but also function that returns center (or any point near center) of given object must be implemented:

…

MPR - Penetration Of Two Objects

Using MPR algorithm for obtaining penetration info about two intersection objects is equally easy as in previous case instead ccdMPRPenetration() function is used:

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言