Numerical Integration I

Source: Internet
Author: User

This article is mainly to implement the particle system

The particle system can simulate a lot of visual like simulating the fog in nature, rain and snow, and some of the cool laser fire in the game.

A particle usually needs a texture to match the globalcompositeoperation lighter property of the flame laser's particle system to overlay the pixel value.

The motion of a particle is only a matter of linear velocity and collision between particles. A particle is a life-time life that can be removed directly or reset properties directly.

Different particle systems, their emission points, the texture life of the various resultant forces need to give different parameters

Let me awaken you to the spirit of physics (believe me!) I have been taught by the Goddess of mathematics! The Goddess is not wrong! )

With your only physical knowledge, you must have read the following equation.

S=s0+v*t

For a short period of time differential

Dx=v*dt

The change of position is the instantaneous speed of a certain moment. We can extend it to the whole small period of time by a very small period of time.

How do you put him in a specific code? DT is a continuous simulation of time with Newton's Law

Have f=m*a

a=d2x/d2t

V=dx/dt

A=dv/dt

This requires only the force and the force to calculate the acceleration

Must be the force of gravity f=m*g G can also represent other forces

Particle system Algorithm Process

1 calculating the resultant force on a particle at some point

2 Finding the acceleration on a particle

3 using numerical integration to find the position of velocity change

Key code

Render (EST) {
This. ALP = sin (pi* (-- This. Ag/this.ag2)); Const FINV = This. Finv.scale ( This. FSS). Rotate ( This. FRD); const [NN1,NN2]=[FINV.X,FINV.Y]; This. Y + = est* ( This. n2+=est*nn2); This. x + = est* ( This. n1+=est*nn1); with(STG.CTX) {save (); FillStyle= ' Pink '; Translate ( This. x, This. Y); Globalalpha= This. ALP; DrawImage (Map,0,0); Restore (); }

The following simulates a smoke somewhat like the exhaust of a car.

Again

In short, different parameters will show different effects

Give the effect of another fireball demo poke me ~

In the next article I will use another integral method to simulate a rigid body, please look forward to ~

Numerical Integration I

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.