tedigc / SeparatingAxisTheorem

A Monogame implementation of the Separating Axis Theorem (SAT) for convex polygon intersection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SeparatingAxisTheorem

A Monogame implementation of the Separating Axis Theorem for convex polygon intersection.

View on nuget or install directly with:

dotnet add package Halfcut.SeparatingAxisTheorem.Lib --version 0.0.2

Usage

using Halfcut.SeparatingAxisTheorem.Lib;

var _polygon1 = PolygonFactory.CreateRectangle(x1, y1, w1, h2);
var _polygon2 = PolygonFactory.CreateRectangle(x2, y2, w2, h2);

var isIntersecting = _polygon1.IntersectsWith(_polygon2);

Demo

Run the demo code with:

git clone git@github.com:tedigc/SeparatingAxisTheorem.git
cd SeparatingAxisTheorem
dotnet build
dotnet run --project SeparatingAxisTheorem.Demo/SeparatingAxisTheorem.Demo.csproj

You can move the rotating square with WASD.

Extensions

  • Circle collision
  • Improve api for translating and rotating polygons
  • Publish as a nuget package
  • Calculate the minimum translation vector (MTV)
  • Convex decomposition for non-convex polygons
  • Exception handling

Created by Ted Cater (tedigc)

About

A Monogame implementation of the Separating Axis Theorem (SAT) for convex polygon intersection


Languages

Language:C# 100.0%