JAVA COLLISION DETECTION AND PHYSICS ENGINE

A 100% Java 2D collision detection and physics engine. Designed to be fast, stable, extensible, and easy to use. dyn4j is free for use in commercial and non-commercial applications

Download

Download

dyn4j is a maven project but can be used in non-maven projects. It supports OSGI and Java 9 modules and is built against Java 1.6. dyn4j has no dependencies.
Maven
<dependency>
    <groupId>org.dyn4j</groupId>
    <artifactId>dyn4j</artifactId>
    <version>4.2.0</version>
</dependency>
Other ways to download:
GitHub Packages   Releases (legacy)

100% Java

Written entirely in Java with zero dependencies running on Java 1.6 or higher.

Tested

Over 2,000 automated JUnit tests, suite of samples, and Sandbox GUI application.

Documented

Getting started is easy with Javadocs, wiki, and more.

Open Source

Open source and free to use in commercial and non-commercial applications.

Take dyn4j for test drive

The sample repo contains a simple Java2D framework (and a JOGL example) along with a number of sample simulations.

View the samples

Getting started is simple

The easiest way to get started is to clone the dyn4j-samples repo locally as shown below.

You can also get started by downloading the latest version of the library, adding it to your project, and then taking a look at the UsingGraphics2D and UsingJogl sample applications. Check out the rest of the samples for additional help.

It's recommend to go through the getting started page first. If you do get stuck, take a look at the javadocs or start a discussion on GitHub.

Learn how to use dyn4j
View the latest Javadocs
Get help from the community
View the latest release notes

QUICK START GUIDE


A quick 2 minute video showing the use of the samples GitHub project to get started using dyn4j

If you'd like to learn more about how dyn4j works, check out the blog or read through the heavily documented source code on GitHub.

Latest Blog Posts

Simple Polygon Simplification

When simulating physical interaction between objects, there are many tradeoffs used to keep performance acceptable for realtime scenarios. The geometry of an object, or it’s shape, is no exception. To accelerate calculations, collision detection systems will enforce rules about what types of shapes are supported - a key example is Convexity. Not all objects are convex, and you might even argue that most aren’t, but we can combine these convex pieces to create non-convex objects.

A Faster Broadphase in dyn4j 4.0.0

Version 4.0.0 had a lot of changes to the API to support better extensibility, testability, and maintainability, but the biggest change was the 30-40% improvement in performance. This type of of performance gain is huge and a boon for sure for all those using the library - but just how was it done?

WordPress to GitHub Pages

In my last post where I talked about the reasons for moving the dyn4j site to GitHub Pages and off of WordPress, I mentioned another post to describe the technical details of the move - this is it! Seriously though, it wasn’t trivial, but that’s in part due to some self-imposed (inflicted?) constraints.