fireworks.frink

View or download fireworks.frink in plain text format


class Fragment
{
   // Position
   var x
   var y
   var z

   // Velocity
   var vx
   var vy
   var vz

   // Physical properties (primarily to calculate drag)
   var radius
   var mass
   var Cd    // Drag coefficient
   var area  // Derived area from radius

   // Color
   var color

   // Boolean flag indicating if this is a shell that is going to explode
   var isShell

   // The lifetime of the fragment
   var lifetime

   // Constructor
   new[x, y, z, vx, vy, vz, radius, mass, Cd, color, isShell, lifetime] :=
   {
      this.x = x
      this.y = y
      this.z = z

      this.vx = vx
      this.vy = vy
      this.vz = vz

      this.radius = radius
      this.mass = mass
      this.Cd = Cd
      area = pi radius^2

      this.color = color

      this.lifetime = lifetime
   }

   // Update the position
   updatePosition[timestep, gravity, airDensity] :=
   {
      // Calculate square of velocity
      v2 = vx^2 + vy^2 + vz^2
      
   }
}

class FireworksShow
{
   var gravity
   var airDensity
   
   new[g=gravity, d=
}


View or download fireworks.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17651 days, 5 hours, 19 minutes ago.