P2.js Physics Engine Learning

Source: Internet
Author: User
P2 Introduction

P2 is a JavaScript-based HTML5 2D physics engine, like box2d, nape and other physical engines, P2 integrates a variety of complex physical formulas and algorithms, can help us easily to achieve collision, rebound and other physical phenomena simulation.

Learning materials

P2 API
Understanding HTML5 Physics Engine P2

Element Introduction

World, this is a simulated physical world in which all rigid bodies and constraints are created and put in.

Body (rigid body), which is an infinitely hard object. Therefore, the distance between any two points on this object is considered to be fixed. The body (rigid body) has its own parameters for setting the position, mass, and speed, and the shape of the rigid body is determined by the shapes created by shape.

Shape, a geometric shape, can be a rectangle, a circle, and so on.

Constraint (constraint), Constraint is a physical connector that controls the degree of freedom of a rigid body. In the 3d World, objects have 6 degrees of freedom (3 translational coordinates and 3 rotational coordinates). In the 2d world, objects have only 3 degrees of freedom (2 translational coordinates and one rotational coordinate). As we all know, the human world is 3d, so our home door should have 6 degrees of freedom, but because the door on one side by the door hinge fixed on the wall, it lost another 5 degrees of freedom, can only follow the door hinge this axis rotation. The door hinge is equivalent to a constraint (constraint).

Contact constraint, which is a special constraint that prevents infiltration overlap between rigid bodies and simulates friction and elasticity. You do not need to create this constraint and the system will automatically create it.

Solver (Solver), the Solver (solver) of the physical world is dedicated to handling constraints.

(not to be continued ...) )

P2.js Physics Engine Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.