using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Azimuth; using Annulus; using Slipstream.StokesFlow; namespace Slipstream.Testbed.Demos { class TranslatingStokesPanel : Demo { StokesPanelBoundaryBody _body; public override void Start(FluidWorld world) { _body = new StokesPanelBoundaryBody(new[] { Vector.Zero }, new[] { Vector.UnitX }, 10, Vector.Zero, 0); world.AddBoundary(_body); Random rand = new Random(1); for (int i = 0; i < 1000; ++i) { world.AddTracerParticle(new Vector(2 * rand.NextDouble() - 1, 2 * rand.NextDouble() - 1) * 100); } } Scalar cycleCount = 0; public override void Update(FluidWorld world) { cycleCount += 1.0 / 60.0; Scalar period = 10; Scalar angularVelocity = (1.0 / period) * (2 * Math.PI); var newPos = new Vector(25 * Math.Sin(angularVelocity * cycleCount), 0); var velocity = new Vector(25 * angularVelocity * Math.Cos(angularVelocity * cycleCount), 0); _body.LinearVelocity = velocity; _body.Position = newPos; Scalar totalEnergyCount; world.EnforceBoundaryConditions(); world.IntegrateTracerParticles(1.0 / 60.0, out totalEnergyCount); } public override void Reset(FluidWorld world) { cycleCount = 0; } public override Blacklight.Core.Cel Draw(FluidWorld world) { var cel = new Blacklight.Core.Cel(); var collage = new Blacklight.Core.Drawables.Collage(); var panelCollage = new Blacklight.Core.Drawables.Collage(); var panel = new Blacklight.Core.Drawables.Rectangle { InsideColor = new Blacklight.Core.Color(0.84, 0.84, 0), ShellColor = new Blacklight.Core.Color(0.84, 0.25, 0), ShellPixelThickness = 0, ShellModelSpaceThickness = 0, SmoothBorder = false, }; panelCollage.AddDrawable(panel, new AffineMatrix( new Vector(_body.PanelLength * 0.5 * 0.66, 0), new Vector(0, 0.5), new Vector(0, 0))); foreach (var panelTransform in _body.PanelTransforms) { collage.AddDrawable(panelCollage, panelTransform); } cel.AddEntity(new Blacklight.Core.Entity { drawable = collage, modelToWorld = _body.ModelToWorld, }); return cel; } } }