slicepicker

slicepicker, tile type

The slicepicker is an interactive tile that offers navigation controls to pick a slice.

Image

In this example, the slice picker controls the ballistic trajectory of a projectile subjected to gravity and wind.

table Angles[angle] = with
  [| as Angle   , as Cos       , as Sin        |]
  [| 85         , 0.08715574275, 0.99619469809 |]
  [| 75         , 0.2588190451 , 0.96592582629 |]
  [| 60         , 0.5          , 0.86602540378 |]
  [| 45         , 0.70710678119, 0.70710678119 |]
  [| 30         , 0.86602540378, 0.5           |]
  [| 15         , 0.96592582629, 0.2588190451  |]
  [|  5         , 0.99619469809, 0.08715574275 |]

table Velocity = with
  [| 100 as Velocity |]
  [|  90 |]
  [|  80 |]
  [|  60 |]
  [|  40 |]
  [|  20 |]

table Wind = with
  [| -4 as Wind |]
  [| -2 |]
  [| -1 |]
  [| 0 |]
  [| 1 |]
  [| 2 |]
  [| 4 |]

table AngleVelocity = cross(Angles, Velocity)
table AngleVelocity = where AngleVelocity.*

table Parameters = cross(AngleVelocity, Wind)
table Parameters[p] = where Parameters.*

Parameters.Angle = Angles.Angle into AngleVelocity
Parameters.Velocity = Velocity.Velocity into AngleVelocity
Parameters.Wind = Wind.Wind

table Time = extend.range(500)
table Trajectory = cross(Time, Parameters)

const dt = 0.1

def process simulate(wind: number; ivx: number, ivy: number) with
  keep x = 0
  keep y = 0
  keep vx = ivx
  keep vy = ivy
  // Return current value
  ix = x
  iy = y
  // Do not allow traversing the ground
  where y + vy*dt <= 0
    vx = -(y/dt/vy) * vx
    vy = -y/dt
  // Integrate 1st order
  x = x + vx * dt
  y = y + vy * dt
  // Integrate 2nd order
  vx = vx + wind * dt
  vy = vy - 9.82 * dt
  return (ix, iy)

Parameters.VelX = Angles.Cos[Parameters.Angle] * Parameters.Velocity
Parameters.VelY = Angles.Sin[Parameters.Angle] * Parameters.Velocity

Trajectory.X, Trajectory.Y = simulate(Parameters.Wind; Parameters.VelX, Parameters.VelY)
  by p scan (Time.N into Trajectory)

Parameters.slice = sliceDashboard("") by p
Trajectory.slice = Parameters.slice

show slicepicker "Ballistic parameters" a1b4 with
  same(Parameters.Angle) as "Angle"
  same(Parameters.Velocity) as "Velocity"
  same(Parameters.Wind) as "Wind"

show table "Trajectory" a5b7 slices:Trajectory.slice with
  Trajectory.X
  Trajectory.Y

maxy = max(Trajectory.Y) * 1.1
maxx = max(Trajectory.X) * 1.1

show scatter "Trajectory" c1f7 slices:Trajectory.slice {
  vaxis { axisMax: #(maxy) }
  haxis { axisMax: #(maxx) }
} with
  Trajectory.X
  Trajectory.Y
  order by Time.N