# Fireworks 3D

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

### WHAT IS IT?

This program models the action of fireworks. Rockets begin at the bottom of the world, shoot upwards into the sky and then explode, emitting showers of falling sparks.

### HOW IT WORKS

Each rocket, represented by a turtle, is launched upward with an initial x y and z velocity. At a certain point in the sky, an explosion occurs, which is represented by a series of turtle hatches. Each hatched turtle inherits the velocity from the original rocket in addition to velocity from the explosion itself. The result is a simulation of a fireworks display.

### HOW TO USE IT

SETUP creates FIREWORKS rockets at the bottom of the screen (MIN-PZCOR). Pressing the GO forever button executes the model continually, launching the rockets. When a rocket hits its peak velocity, it explodes into FRAGMENTS pieces.

GRAVITY determines the gravitational strength in the environment. A larger value will give a greater gravitational acceleration, meaning that particles will be forced to the ground at a faster rate. The inverse is true for smaller values.

INITIAL-X-VEL sets the initial x-velocity of each rocket to a random number between the negative and positive value of the number indicated on the slider.

INITIAL-Y-VEL sets the initial y-velocity of each rocket to a random number between the negative and positive value of the number indicated on the slider.

INITIAL-Z-VEL sets the initial z-velocity of each rocket to a random number between 0 and the number indicated on the slider plus ten. This is to ensure that there is a range of difference in the initial z-velocities of the fireworks.

FADE-AMOUNT determines the rate at which the explosion particles fade after the explosion.

If TRAILS? is true the fragments of each explosion will have their pens down so the paths of each fragment are visible (and they look like real fireworks).

If SPIN-OBSERVER? is on the Observer will spin around the world as the model runs.

The model will launch a new set of rockets every DELAY seconds.

This model has been constructed so that all changes in the sliders and switches will take effect in the model during execution. So, while the GO button is still down, you can change the values of the sliders and the switch, and you can see these changes in the world.

### THINGS TO NOTICE

Experiment with the INITIAL-X-VEL, INITIAL-Y-VEL, and INITIAL-Z-VEL sliders. Observe that initial x and y velocities of zero launch the rockets straight upwards. When the initial x or y velocities are increased, notice that some rockets make an arc in the sky.

With the initial z-velocity, observe that, on a fixed GRAVITY value, the heights of the fireworks are lower on smaller initial z-velocities and higher on larger ones. Also observe that each rocket explodes at a height equal to or a little less than its apex.

### THINGS TO TRY

Observe what happens to the model when the GRAVITY slider is set to different values. Watch what happens to the model when GRAVITY is set to zero. Can you explain what happens to the fireworks in the model? Can you explain why this phenomenon occurs? What does this say about the importance of gravity? Now set the GRAVITY slider to its highest value. What is different about the behavior of the fireworks at this setting? What can you conclude about the relationship between gravity and how objects move in space?

### EXTENDING THE MODEL

The fireworks represented in this model are only of one basic type. A good way of extending this model would be to create other more complex kinds of fireworks. Some could have multiple explosions, multiple colors, or a specific shape engineered into their design.

### NETLOGO FEATURES

An important aspect of this model is the fact that each particle from an explosion inherits the properties of the original firework. This informational inheritance allows the model to adequately represent the projectile motion of the firework particles since their initial x, y, and z velocities are relative to their parent firework.

To visually represent the fading property of the firework particles, this model made use of the reporter 'scale-color'. As the turtle particles fall to the ground, they hold their pens down and gradually scale their color to black. As mentioned above, the rate of fade can be controlled using the FADE-AMOUNT slider.

### HOW TO CITE

If you mention this model in an academic publication, we ask that you include these citations for the model itself and for the NetLogo software:

- Wilensky, U. (2006). NetLogo Fireworks 3D model. http://ccl.northwestern.edu/netlogo/models/Fireworks3D. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use:

- Copyright 2006 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Fireworks3D for terms of use.

### COPYRIGHT NOTICE

Copyright 2006 Uri Wilensky. All rights reserved.

Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:

a) this copyright notice is included.

b) this model will not be redistributed for profit without permission from Uri Wilensky. Contact Uri Wilensky for appropriate licenses for redistribution for profit.

This is a 3D version of the 2D model Fireworks.

## Comments and Questions

turtles-own [ col ;sets color of an explosion particle x-vel ;x-velocity y-vel ;y-velocity z-vel ;z-velocity ] breed [ rockets rocket ] breed [ frags frag ] rockets-own [ terminal-z-vel ] ;velocity at which rocket will explode frags-own [ dim ] ;used for fading particles ;SETUP ;----- ;This function clears the graphics window of all patches and turtles. to setup ca orbit-down 90 end ;GO ;-- ;If there are no turtles, then it creates a random number ;according to the slider FIREWORKS and sets all the initial ;values for each firework. ;It then calls PROJECTILE-MOTION, which launches and explodes the fireworks. to go every delay [ launch-rockets ] ;we don't want the model to run too quickly because otherwise, ;you wouldn't be able to see the fireworks every 0.06 [ if spin-observer? [ orbit-right 2 ] ] every 0.03 [ fall-down display ] if not any? turtles [ tick ] end to launch-rockets if not any? turtles [ cd create-rockets random (fireworks + 1) [ setxyz random-xcor random-ycor min-pzcor set shape "circle" set size 0.1 set x-vel ((random-float (2 * initial-x-vel)) - (initial-x-vel)) set y-vel ((random-float (2 * initial-y-vel)) - (initial-y-vel)) set z-vel ((random-float initial-z-vel) + initial-z-vel * 2 ) set col ((random 14) + 1) * 10 - 5 ;; reports a random 'primary' color i.e. 5, 15, 25, etc. set color (col + 2) set terminal-z-vel (random-float 2.0) ;; at what speed does the rocket explode? ] ] end to fall-down ask rockets [ projectile-motion ] ask frags [ projectile-motion ] if trails? [ ask frags [ set pen-size 2 pd ] ] end ;PROJECTILE-MOTION ;----------------- ;This function simulates the actual free-fall motion of the turtles. ;If a turtle is a rocket it checks if it has slowed down enough to explode. to projectile-motion ;; turtle procedure set z-vel (z-vel - (gravity / 5)) kill-wrapped setxyz xcor + (x-vel / 10) ycor + (y-vel / 10) zcor + (z-vel / 10) ifelse (breed = rockets) [ if (z-vel < terminal-z-vel) [ explode die ] ] [ fade ] end ;EXPLODE ;------- ;This is where the explosion is created. ;EXPLODE calls hatch a number of times indicated by the slider FRAGMENTS. to explode ;; turtle procedure hatch-frags fragments [ set dim 0 set size 0.1 set shape "circle" tilt-up asin (1.0 - random-float 2.0) roll-right random-float 360 set x-vel (x-vel * .5 + (random-float 2.0) - 1) set y-vel (y-vel * .5 + (random-float 2.0) - 1) set z-vel (random-float 2.0) ifelse trails? [ pd ] [ pu ] ] end ;FADE ;---- ;This function changes the color of a frag. ;Each frag fades its color by an amount proportional to FADE-AMOUNT. to fade ;; frag procedure set dim dim - (fade-amount / 10) set color scale-color col dim -5 .5 if ( color < col - 1 ) [die] end ;KILL-WRAPPED ;-------- ;This function is used to keep the turtles within the vertical bounds of the world. ;If they go above or below the top or bottom of the world kill them. to kill-wrapped ;; turtle procedure if (zcor + z-vel / 10) > (max-pzcor + 0.4) [ die ] if (zcor + z-vel / 10) < (min-pzcor - 0.4) [ die ] end ; Copyright 2006 Uri Wilensky. All rights reserved. ; The full copyright notice is in the Information tab.

There are 3 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Fireworks 3D.png | preview | Preview for 'Fireworks 3D' | over 9 years ago, by Uri Wilensky | Download |

This model does not have any ancestors.

This model does not have any descendants.