A particle system takes small time-steps and updates each particle's location and velocity based on the forces acting on it.

Similar documents
Lab 4: Gauss Gun Conservation of Energy

Gravitational Potential Energy

PHY 221 Lab 7 Work and Energy

Chapter Four Holt Physics. Forces and the Laws of Motion

Chapter 4: Newton's Laws of Motion

PHY 221 Lab 9 Work and Energy

Electric Fields -- Conceptual Solutions. 1.) What does an electric field actually tell you? That is:

Introduction. Pre-Lab Questions: Physics 1CL PERIODIC MOTION - PART II Spring 2009

LAB 2 - ONE DIMENSIONAL MOTION

Free-Body Diagrams: Introduction

Spring Thing: Newton s Second Law. Evaluation copy

The dimensions of an object tend to change when forces are

BIT1002 Newton's Laws. By the end of this you should understand

Introduction. Pre-Lab Questions: Physics 1CL PERIODIC MOTION - PART II Fall 2009

July 19 - Work and Energy 1. Name Date Partners

LAB 6: WORK AND ENERGY

If there is now a constant air resistance force of 35 N, what is the new maximum height the ball attains?

the gamedesigninitiative at cornell university Lecture 17 Physics and Motion

STEP Support Programme. Mechanics STEP Questions

TEACHER BACKGROUND INFORMATION FORCE

Physics A - PHY 2048C

Learning Guide for Chapter 7 - Organic Reactions I

Episode 220: Momentum and its conservation

Forces. Unit 2. Why are forces important? In this Unit, you will learn: Key words. Previously PHYSICS 219

University of Maryland Department of Physics. Spring 2009 Final Exam 20. May (175 points) Post grades on web? (Initial, please) Yes No

LAB 6: WORK AND ENERGY

5 th Grade Force and Motion Study Guide

Casting Physics Simplified Part Two. Frames of Reference

Particle Systems. CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2017

Equilibrium of rigid bodies Mehrdad Negahban (1999)

PHY 221 Lab 5 Diverse Forces, Springs and Friction

ACTIVITY 2: Motion and Energy

Engineering Science OUTCOME 2 - TUTORIAL 3 FREE VIBRATIONS

MITOCW ocw nov2005-pt1-220k_512kb.mp4

Mass on a Horizontal Spring

Partner s Name: EXPERIMENT MOTION PLOTS & FREE FALL ACCELERATION

MITOCW free_body_diagrams

3. What type of force is the woman applying to cart in the illustration below?

Gravity Pre-Lab 1. Why do you need an inclined plane to measure the effects due to gravity?

5-Sep-15 PHYS101-2 GRAPHING

Universal Gravitation. A Core Learning Goals Activity for Science and Mathematics

PHY221 Lab 2 - Experiencing Acceleration: Motion with constant acceleration; Logger Pro fits to displacement-time graphs

Section 1 Changes in Motion. Chapter 4. Preview. Objectives Force Force Diagrams

Practice Exam 2. Multiple Choice Identify the choice that best completes the statement or answers the question.

Forces. Name and Surname: Class: L E A R N I N G O U T C O M E S. What is a force? How are forces measured? What do forces do?

Time scales. Notes. Mixed Implicit/Explicit. Newmark Methods [ ] [ ] "!t = O 1 %

HSC PHYSICS ONLINE B F BA. repulsion between two negatively charged objects. attraction between a negative charge and a positive charge

Chapter 5. The Laws of Motion

Conservation of Momentum Using PASCO TM Carts and Track to Study Collisions in One Dimension

Chapter 4. Forces and Newton s Laws of Motion. continued

Chapter 4 Dynamics: Newton s Laws of Motion

Force. The cause of an acceleration or change in an object s motion. Any kind of a push or pull on an object.

Investigate the relationship between the extension of a spring and the applied force

Newton s First Law and IRFs

Name per due date mail box. Friction Lab. Challenge - move your wooden block from start to finish with the least amount of force.

Physics for Scientists and Engineers. Chapter 5 Force and Motion

Ch.8: Forces as Interactions

Chapter 8. Conservation of Energy

Newton s Laws of Motion

Structural Dynamics Prof. P. Banerji Department of Civil Engineering Indian Institute of Technology, Bombay. Lecture - 1 Introduction

Good Vibes: Introduction to Oscillations

Forces are impossible to see! We can only see the effects! Essentially forces are pushes or pulls.

Chapter 5 - Differentiating Functions

the gamedesigninitiative at cornell university Lecture 18 Box2D Physics

AP Physics 1 Summer Assignment

Measuring Force You may have measured forces using a spring scale. The of the spring in the scale depends on the amount of (a type of ) acting on it.

The Spring-Mass Oscillator

3.2 Forces and Motion

ELECTRICAL PHENOMENA

One Dimensional Collisions 1 Fall 2018

Chapter 5 Force and Motion

Pushes and Pulls. Example- an apple falling on a tree exerts a downward force with a magnitude of about 1 newton.

Experimenting with Forces

Work and Energy Experiments

AQA Forces Review Can you? Scalar and vector quantities Contact and non-contact forces Resolving forces acting parallel to one another

AP Physics B Summer Assignment Packet 3

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Physics Department

A student suspended a spring from a laboratory stand and then hung a weight from the spring. Figure 1

Newton s Law of Motion

LAB 4: FORCE AND MOTION

AP Physics Electromagnetic Wrap Up

Chapter 4 Force and Motion

MITOCW MITRES18_005S10_DiffEqnsMotion_300k_512kb-mp4

Electric and Magnetic Forces

Chapter Introduction. Motion. Motion. Chapter Wrap-Up

Rotational Motion. Figure 1: Torsional harmonic oscillator. The locations of the rotor and fiber are indicated.

Physics for Scientists and Engineers 4th Edition, 2017

4. Find the average velocities and average accelerations of a particle moving in 1-D given its position at various times.

Newton s Wagon. Materials. friends rocks wagon balloon fishing line tape stopwatch measuring tape. Lab Time Part 1

EECE202 NETWORK ANALYSIS I Dr. Charles J. Kim

Figure Two. Then the two vector equations of equilibrium are equivalent to three scalar equations:

PHYS 121: Work, Energy, Momentum, and Conservation Laws, Systems, and Center of Mass Review Sheet

Bell Ringer: What is Newton s 3 rd Law? Which force acts downward? Which force acts upward when two bodies are in contact?

Lecture 5. Dynamics. Forces: Newton s First and Second

Honors Physics Review

1 Oscillations MEI Conference 2009

44 Force extension characteristics for a spring / elastic material

Dynamics of Machines. Prof. Amitabha Ghosh. Department of Mechanical Engineering. Indian Institute of Technology, Kanpur. Module No.

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Physics Department. Physics 8.01 Fall Term 2006

Unit 7 ~ Learning Guide Name:

Transcription:

A particle system is a simple physics model that deals only with point- masses and forces. That means that as opposed to rigid-body models objects in particle systems occupy no volume. Their behavior is quite simple but very powerful. What is a particle system? A particle is an object with a location and a mass. It is acted upon by any number of forces. Its acceleration is calculated by f = ma, where f is the vector sum of all the forces acting on it. Particles have three properties that you may want to manipulate: Mass: The mass of the particle. The greater the mass, the more force is required to accelerate it. Position: You will likely want to give your particle an initial position. Fixed: This boolean value indicates whether a particle's position is being controlled manually or by the forces in the system. A fixed particle can be attached to a single point in space, or the mouse, or may be moved simply by setting its position. Often a whole system of particles will be attached to a single fixed particle and will move with it. A particle system takes small time-steps and updates each particle's location and velocity based on the forces acting on it. The most commonly used forces are gravity, drag, springs, and magnets. Gravity applies a constant additive acceleration to every particle. It can point in any direction and can be turned off. Drag slows the movement of particles. It is equivalent to air-resistance. Springs are forces that exist between two particles that pull the two particles together with a force proportional to the distance of their separation. Networks of particles connected with multiple spring exhibit surprising and lovely behavior. Springs have three parameters: Rest length: The rest length of a spring is the length at which it no longer pulls. Strength: The strength of the spring is how hard it pulls when it is stretched. Damping: The amount of energy absorbed by the spring as it bounces. Damping is necessary so that the spring doesn't keep oscillating for too long. Magnets are forces that attract and repel all particles inversely proportionally to their proximity to the source. Magnets are attached to a particle so that they have a location associated with them and so that they can be conveniently drawn. But the host particle is not affected by its own magnetism. Magnets have one important parameter, their strength.

Using the particle systems in Processing Particle systems are available with the PSystem plugin to Processing. For general instructions on loading plugins, see plugin system documentation. Generally, though, loading the plugin looks like this: //ps is a global variable of type PSystem PSystem ps;... //Then in setup() ps = (PSystem)loadPlugin("PSystem"); Then you must go to "Sketch -> Add file..." and locate and add "PSystem.jar." You use it by simply adding particles and forces (primarily springs). The rest will be taken care of by the system. Particles and springs have certain native properties and behaviors which you can change at will. From here down, we will assume that the particle system has been loaded into a global variable called "ps." Creating a new particle type It is not absolutely necessary to create a new particle type because the Particle class defines a simple particle that renders as a small box. But if you want anything more exotic, you will want to write your own. A new particle type is just a new class that extends the Particle class that gets loaded with the PSystem plugin. All particles automatically have a few properties defined on them. Their position, for instance is updated automatically by the system, and is accessed by the member variable "pos[]" which is an array of three floats. pos[0], pos[1], and pos[2] are the X, Y, and Z positions respectively. Remember that inside the particle's code itself, this variable is just called pos, but outside a particle stored in a variable called particlename, the X position would be accessed this way: particlename.pos[0] The syntax for defining a particle type looks like this: class BoxParticle extends Particle { BoxParticle(float x, float y, float z) { super(x, y, z); // initialization code here. } void draw() { push(); translate(pos[0], pos[1], pos[2]); box(5, 5, 5); pop();

} } This defines a simple particle that moves to its position in loop and draws a small box there. (Defining this particle is actually redundant because this is the default behavior of the "Particle" class anyway.) This techniqe of pushto-position, draw, and pop is a good model to keep. This way all particles exist in a shared coordinate system, but can draw themselves relative to their own position. To spawn a new particle of this type, you would use the line: boxpart = new BoxParticle(); ps.addparticle(boxpart); You must obviously do this after you load the PSystem, but don't do it in loop() unless you want to be spawning a new particle every frame (which would quickly bog down the system). Since particles don't do much other than fall due to gravity without springs or other forces attached, it is likely we want to hold onto a reference to the new particle when we spawn it so we can use it later. Here is an example of two particles being spawned and referenced by variables so that they can be attached by a spring. BoxParticle a = new BoxParticle(0, 0, 0); ps.addparticle(a); BoxParticle b = new BoxParticle(100, 100, 100); ps.addparticle(a); Spring s = new Spring(a, b); ps.addforce(s); In the above code, we have spawned two particles and stored them in the variables "a" and "b". We have used a constructor that also sets the position of the new particle to the values entered. Then we have connected a and b with a spring, which we have assigned to a variable called "s" in case we should decide that we want to modify this spring later. We must add the particles and the force to the particle system with the "add..." methods if we want the PSystem to keep track of them. Collisions A simple collision model based on spherical boundaries is built in. It acts as a strong repelling magnet that is only activated if another particle's radius of collision intersects this particle's radius of collision. These are not like true elastic or inelastic collisions, but it models them well enough to look OK. Collision is turned off by default. In order for two particles to react in collision, collision must be turned on for both particles. This is done using particle.enablecollision(collisionradius);

where collisionradius is the spherical radius of the particle's collision boundary. Note that this radius may or may not be directly related to how the particle is drawn. You may institute a collision boundary outside the drawn bounds of the particle to act as a force-field. Collision can also be disabled again with particle.disablecollision(); Collision is modelled as a strong repelling force that only activates below the collision radius. It has its minimum strength where the intrusion is minor, and takes its maximum strength when the collision is more severe. You can set the minimum and maximum collision strengths per particle: particle.mincollisionforce = SOMETHING; particle.maxcollisionforce = SOMETHING_BIGGER; Old age and death Old age and death are nothing to fear, they are well-supported. Every particle has an integer "age" field that is updated automatically each frame after it is added to the particle system. particle.age You can make a particle die and disappear by calling its "die()" function: particle.die(); Die should take care of removing the particle from the particle system and removing any forces that are dependent on it. Various stuff Gravity: ps.setgravity(gy); The setgravity function takes a float value indicating how strong gravity is in the downward Y direction. Calling this function will set gravity in the X and Z directions to zero (which is normal). It makes sense to call gravity once in your setup function because you typically only need to set the global gravity once (in setup(), say) unless there is a circumstance in your program that makes gravity change. The default gravity value is 0.03. ps.setgravity(gx, Gy, Gz); This function is just like the one above, but it lets you also specify the gravity in the X and Z directions in case things in your world should be falling to the side or forwards or backwards. The default gravity values are Gx: 0.0, Gy: 0.03, Gz: 0.0.

ps.drag = SOME_FLOAT; Drag is a float value indicating how much drag resists the movement of particles. It is equivalent to air-resistance. Setting the drag high is like putting it in water. Too little drag will keep the system from finding equilibrium. The default drag value is 0.03. particle.setpos(x, Y, Z); This will set "particle's" position to (X, Y, Z). particle.fixed() For a variable of a particle type called "particle" this boolean function indicates whether this particle is fixed or free to move by the forces applied to it. Note that a fixed particle can be moved around, but the PSystem itself will not be doing it automatically. particle.fix() Sets a particle to fixed. particle.unfix() Sets a particle to un-fixed. particle.fix(int axis, float value) Fixes a particle in a particular axis only. Axes are 0=X, 1=Y, 2=Z. This will in effect constrain a particle to a line. You can constrain two different axes by calling this with two different axes. A particle's "fixed()" function will not return true unless it is fixed in all dimensions. particle.pos Pos is an array of three floats that contains the particle's position in space. particle.mass = SOME_FLOAT; For a variable of a particle type called "particle" this variable is the mass of the particle. The default mass is 1.0. particle.enablecollision(collisionradius); Enables collision with a radius of collisionradius for this particle. Collision will only occur between two particles who both have collision enabled. particle.disablecollision(); Disables collision for this particle. ps.addspring(particlea, particleb); This is a convenience function that adds a new spring to the system between particlea and particleb. By default the spring has a rest length of 18.0, a strength of 0.005, and a damping of 0.001. If you want to modify this spring's properties, you might want to hold the spring in a variable by writing a line like this: Spring s = addspring(particlea, particleb); addspring is equivalent to creating a new Spring and also adding it to the PSystem. addspring(particlea, particleb, strength, damping, length);

This function is just like the above addspring(), but you can manually specify the strength, damping, and length. If you make a spring too strong or give it too little or negative damping, you will witness a very interesting numerical explosion. It's worth trying to see it happen. ps.drawforces = BOOLEAN_VALUE; This field tells a particle system whether or not to draw each force. By default Springs are the only forces that know how to draw themselves, but you can add a draw method to any custom force, and it will automatically draw if ps.drawforces is true, which is the default. ps.drawsprings(); This function will be called automatically if drawforces is true (the default), but if you set drawforces to false, you may decide to call this manually. spring.restlength = SOME_FLOAT; For a Spring variable "spring" this variable is the rest length of the spring. spring.damping = SOME_FLOAT; For a Spring variable "spring" this variable is the damping of the spring. spring.strength = SOME_FLOAT; For a Spring variable "spring" this variable is the strength of the spring. ps.defaultspringstrength = SOME_FLOAT; This sets the default spring strength for new springs that are created after the function is called to this value. This way you can create many springs with the same strength. ps.defaultspringdamping = SOME_FLOAT; This sets the default spring damping for new springs that are created after the function is called to this value. This way you can create many springs with the same damping. ps.defaultspringrestlength = SOME_FLOAT; This sets the default spring rest length for new springs that are created after the function is called to this value. This way you can create many springs with the same rest length. ps.addmagnet(particlea); This function adds a new magnet to the system whose location is attached to particlea. By default the magnet has a strength of 1.0. If you want to modify this magnet's properties, you might want to hold the magnet in a variable by writing a line like this: Magnet m = addmagnet(particlea); It is possible to attach a magnet to a particle that is fixed or moving. addmagnet(particlea, strength); This function is just like the above addmagnet(), but you can manually specify the strength. magnet.strength = SOME_FLOAT;

For a Magnet variable "magnet" this variable is the strength of the magnet.