GithubHelp home page GithubHelp logo

kerwinzxc / physicsengine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bajdcc/physicsengine

0.0 2.0 0.0 35 KB

Physics Engine inspired by matter.js

Home Page: http://www.cnblogs.com/bajdcc/p/5925837.html

C# 100.00%

physicsengine's Introduction

PhysicsEngine

Physics Engine inspired by matter.js

最近发现了Github上的开源物理引擎项目Matter.js,对它很感兴趣,发现源码并不算长,算上注释大约1万行左右,值得剖析一番。Matter.js实现一个最小化的2D物理引擎,性能不错,故打算用C#重写并学习之。

由于JS是弱类型,而C#是强类型的,所以不得不还原相应的类型。在重写过程中,我也发现了源码中的一些问题,以及代码冗余,不过都无关紧要。在一万行之内实现一个简单的物理引擎本来就很令人激动了,这样可以以最小的工作量来熟悉物理引擎。

重写过程中,渲染用自带GDI实现,所以只需考虑物理引擎中的代码逻辑即可。因需要最简化代码,故有些内容如Sleep等就略过了,只考虑核心部分,即力的仿真和碰撞检测。

最终,我们的物理引擎有下列几个部分:

  • 几何体树
  • 物理学意义上的基本对象(如点、点集、边界等)
  • 简单的碰撞检测(宽、窄)
  • 位置修正
  • 速度修正

physicsengine's People

Contributors

bajdcc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.