Skip to content

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

Notifications You must be signed in to change notification settings

tedigc/SeparatingAxisTheorem

Repository files navigation

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;

class Game {
 
  private Polygon _polygon1;
  private Polygon _polygon2;
    
  public Game() {
    _polygon1 = PolygonFactory.CreateRectangle(x1, y1, w1, h2);
    _polygon2 = PolygonFactory.CreateRectangle(x2, y2, w2, h2);
  }
    
  public void Update(float dt) {
    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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy