Skip to content

Commit

Permalink
added docs, changelog, updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
hamaluik committed Feb 15, 2020
1 parent b385066 commit 75189da
Show file tree
Hide file tree
Showing 49 changed files with 10,750 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.vscode
bin/
dox.xml
*.zip

# Created by https://www.gitignore.io/api/osx,linux,windows,visualstudiocode

Expand Down
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# adapted from https://github.com/andyli/HaxeCI/blob/master/.travis.yml
language: haxe

env:
matrix:
- TARGET=interp

haxe:
- stable
- development
Expand All @@ -20,7 +16,7 @@ install:
- haxelib install glm

script:
- haxe test.${TARGET}.hxml
- haxe test.hxml

branches:
only:
Expand Down
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.0] - 2020-02-15
### Added
- Added transformation support to all provided shape classes
- Added tests for most shapes (not lines)
- Added tests for transformed shape collision calculations
- Added API documentation to all public interfaces

### Changed
- Changed `Shape.origin` getter/setter to a single `Shape.centre` getter
- Changed shape contructors to align with using transforms instead of an initial offset

## [0.4.0] - 2019-02-21
### Added
- Added 3D shapes
- Added 2D shapes
- Added some API documentation

### Changed
- Split 2D and 3D into their own packages: `headbutt.twod` and `headbutt.threed`
- Changed `Shape.centre` to `Shape.origin`

## [0.3.0] - 2017-07-01
- Initial release

[Unreleased]: https://github.com/hamaluik/headbutt/compare/v0.5.0...HEAD
[0.5.0]: https://github.com/hamaluik/headbutt/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/hamaluik/headbutt/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/hamaluik/headbutt/releases/tag/v0.3.0
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2017 Kenton Hamaluik
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
93 changes: 12 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ A GJK and EPA collision engine made with pure [Haxe](http://haxe.org/).
Create either 2D shapes or 3D shapes by implementing the appropriate interface: `headbutt.twod.Shape` / `headbutt.threed.Shape`. Or use one of the pre-defined shapes given in `headbutt.twod.shapes` / `headbutt.threed.shapes`:

* 2D
+ `Circle`
+ `Line`
+ `Rectangle`
+ `Polygon`
* `Circle`
* `Line`
* `Rectangle`
* `Polygon`
* 3D
+ `Sphere`
+ `Line`
+ `Box`
+ `Polyhedron`
* `Sphere`
* `Line`
* `Box`
* `Polyhedron`

Then, instantiate an instance of the appropriate `Headbutt`:

Expand All @@ -42,82 +42,13 @@ var penetration: Null<Vec2> = hb2.intersect(shapeA, shapeB);

## API

### 2D

```haxe
// headbutt.twod.Shape
interface Shape {
public var origin(get, set): Vec2;
public function support(direction: Vec2): Vec2;
}
```

```haxe
// headbutt.twod.Headbutt
class Headbutt {
/**
The maximum number of simplex evolution iterations before we accept the
given simplex. For non-curvy shapes, this can be low. Curvy shapes potentially
require higher numbers, but this can introduce significant slow-downs at
the gain of not much accuracy.
*/
public var maxIterations:Int = 20;
/**
Create a new Headbutt instance. Headbutt needs to be instantiated because
internally it stores state. This may change in the future.
*/
public function new();
/**
Given two convex shapes, test whether they overlap or not
*/
public function test(a: Shape, b: Shape): Bool;
/**
Given two shapes, test whether they overlap or not. If they don't, returns
`null`. If they do, calculates the penetration vector and returns it.
*/
public function intersect(a: Shape, b: Shape): Null<Vec2>;
}
```

### 3D

```haxe
// headbutt.threed.Shape
interface Shape {
public var origin(get, set): Vec2;
public function support(direction: Vec2): Vec2;
}
```

```haxe
// headbutt.threed.Headbutt
class Headbutt {
/**
The maximum number of simplex evolution iterations before we accept the
given simplex. For non-curvy shapes, this can be low. Curvy shapes potentially
require higher numbers, but this can introduce significant slow-downs at
the gain of not much accuracy.
*/
public var maxIterations:Int = 20;
/**
Create a new Headbutt instance. Headbutt needs to be instantiated because
internally it stores state. This may change in the future.
*/
public function new();
/**
Given two convex shapes, test whether they overlap or not
*/
public function test(a: Shape, b: Shape): Bool;
}
```
[API documentation is available.](https://hamaluik.github.com/headbutt/)

## Benchmarks

Benchmarks were run for each target using the results from `haxe bench.hxml`. The
benchmarks were collected on a Ryzen 3600 CPU with 32 GB of DDR4 3200 MHz ram.

| Test | Intersect | Cpp (μs/iter) | Hashlink (μs/iter) | Node/Javascript (μs/iter) | Python (μs/iter) | Interp (μs/iter) |
|:-----|:---------:|---------:|-------:|-------:|-------:|-------:|
| line/line ||0.5 ± 0.1 | 4.4 ± 0.1 | 0.3 ± 1.1 | 18.6 ± 0.1 | 10.8 ± 0.1 |
Expand Down
1 change: 1 addition & 0 deletions docs/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><!-- use theme color or fallback --><!--use textcolor from settings, otherwise create a contrasting color to theme color--><head><meta charset="utf-8"/><link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet"/><link href="./bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet"/><link href="./bootstrap/css/bootstrap-select.min.css" rel="stylesheet"/><link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700,700italic,400italic" rel="stylesheet" type="text/css"/><link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,600,600italic,400" rel="stylesheet" type="text/css"/><link href="https://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css" rel="stylesheet" type="text/css"/><script src="./jquery-1.9.1.min.js"></script><script src="./bootstrap/js/bootstrap.min.js"></script><script src="./bootstrap/js/bootstrap-select.min.js"></script><link href="./styles.css" rel="stylesheet"/><link href="./extra-styles.css" rel="stylesheet"/><link href="./haxe-nav.css" rel="stylesheet"/><script>var dox = {rootPath: "./",platforms: ["dox"]};</script><script src="./nav.js"></script><script src="./index.js"></script><link rel="icon" href="./favicon.ico" type="image/x-icon"/><title>File not found - Headbutt</title></head><body><style>.navbar .brand {display: inline-block;float: none;text-shadow: 0 0 0 transparent;</style><nav class="nav"><div class="navbar"><div class="navbar-inner" style="background:#FAFAFA; border-bottom:1px solid rgba(0,0,0,.09)"><div class="container"><a class="brand" style="color:#000000" href="./">Headbutt</a></div></div></div></nav><div class="container main-content"><div class="row-fluid"><div class="span3"><div class="well sidebar-nav"><form class="form-search" id="searchForm"><div class="input-prepend input-block-level"><span class="add-on"><i class="icon-search"></i></span><input id="search" type="text" placeholder="Filter" autocomplete="off"/></div></form></div><div class="well sidebar-nav"><div id="nav"></div></div></div><div class="span9"><script type="text/javascript">$(document).ready(errorSearch);</script><h1><small>404</small> Page not found</h1><p>Page not found, sorry.</p></div></div></div><footer class="section site-footer" style="background:#FAFAFA"><div class="container"><div class="copyright"><p style="color:#000000">This documentation is generated for version 0.5.0</p><p style="color:#000000">&copy; 2020 &nbsp;</p></div></div></footer><script src=".//highlighter.js"></script><link href="./highlighter.css" rel="stylesheet"/></body></html>
Loading

0 comments on commit 75189da

Please sign in to comment.