Boids.MainWindow.Animate C# (CSharp) Method

Animate() private method

private Animate ( Data d ) : void
d Data
return void
    private void Animate(Data[] d) {
      if (frames == 0) stopwatch.Start();
      frames++;
      ShowStats();
     
      Vector3D unitY = new Vector3D(0.0, 1.0, 0.0);
      for (var index = 0; index < NumBoids; index++) {
        Data data = d[index];
        Transform3DGroup group = new Transform3DGroup();
        Vector3D velocity = data.velocity;
        velocity.Normalize();
        BoidModels[index].Transform = null;
        double theta = Math.Acos(Vector3D.DotProduct(velocity, unitY) / (velocity.Length * unitY.Length)) * (180.0/Math.PI);
        double len = data.velocity.Length;
        ScaleTransform3D s = new ScaleTransform3D(2.0, 2.0, 2.0);
        Vector3D vectord3 = new Vector3D(0.0, 1.0, 0.0);
        AxisAngleRotation3D rotation = new AxisAngleRotation3D(Vector3D.CrossProduct(vectord3, velocity), theta);
        RotateTransform3D rt = new RotateTransform3D(rotation);
        TranslateTransform3D tt = new TranslateTransform3D(data.position - data.velocity);
        group.Children.Add(s);
        group.Children.Add(rt);
        group.Children.Add(tt);
        BoidModels[index].Transform = group;
      }
      var delay = (int)this.FPS.Value; 
      //if (delay > 0) 
          System.Threading.Thread.Sleep(delay);
    }