I've always wanted to try something like this out sometimes. I know not many people are huge fans of maths, but who knows? It could come in handy, and maybe one day I'll polish it into a proper project.
Feel free to use or tweak the engine if you want to use it, just credit me. (Not that it's particularly great, but it's something.) Oh, and if you see any errors, tell me in the comments. (Most people who need to copy an engine usually benefit from an explanation of how it works, so I included that in the project.)