public override int Operate() { //get the two current fish and frame Fish a = PatternLearning.FishA; Fish b = PatternLearning.FishB; int frame = PatternLearning.CurrentFrame; int ToReturn = 0; //depending on the variable type, return the different values switch (Value) { case FilterData.Acc: ToReturn = (int)(a.GetVelocity(frame) - a.GetVelocity(frame - 1)).GetMagnitude(); break; case FilterData.Dir: ToReturn = (int)a.GetVelocity(frame).GetMagnitude(); break; case FilterData.Pos: ToReturn = (int)(a.Path[frame] - b.Path[frame]).GetMagnitude(); break; case FilterData.Vel: ToReturn = (int)a.GetVelocity(frame).GetMagnitude(); break; } return(ToReturn); }
public void UpdateVisuals() { //erase visuals Visuals.Clear(Color.White); //ratio of drawing board width to video Vector PixelRatio = new Vector(DrawingWindow.Width * TankCount.x / Dimensions.x, DrawingWindow.Height * TankCount.y / Dimensions.y); //the male fish to draw Fish male = Tanks[CurrentTankIndex].Male; //the female fish to draw Fish female = Tanks[CurrentTankIndex].Female; //draw the male with a circle for the head and a blue line denoting the direction of the body Pen BluePen = new Pen(Brushes.Blue); Point Male_P = new Point((int)((male.Path[CurrentFrame].x % (Dimensions.x / TankCount.x)) * PixelRatio.x), (int)((male.Path[CurrentFrame].y % (Dimensions.y / TankCount.y)) * PixelRatio.y)); Visuals.DrawEllipse(BluePen, Male_P.X - ellipseSize / 2, Male_P.Y - ellipseSize / 2, ellipseSize, ellipseSize); Visuals.DrawLine(BluePen, Male_P.X, Male_P.Y, Male_P.X + (float)Math.Sin(male.GetVelocity(CurrentFrame).GetMagnitude() * Math.PI / 180) * 30, Male_P.Y + (float)Math.Cos(male.GetVelocity(CurrentFrame).GetAngle() * Math.PI / 180) * 30); //draw the female with a circle for the head and a pink line denoting the direction of the body Point Female_P = new Point((int)((female.Path[CurrentFrame].x % (Dimensions.x / TankCount.x)) * PixelRatio.x), (int)((female.Path[CurrentFrame].y % (Dimensions.y / TankCount.y)) * PixelRatio.y)); Pen PinkPen = new Pen(Brushes.HotPink); Visuals.DrawEllipse(PinkPen, Female_P.X - ellipseSize / 2, Female_P.Y - ellipseSize / 2, ellipseSize, ellipseSize); Visuals.DrawLine(PinkPen, Female_P.X, Female_P.Y, Female_P.X + (float)Math.Sin(female.GetVelocity(CurrentFrame).GetAngle() * Math.PI / 180) * 30, Female_P.Y + (float)Math.Cos(female.GetVelocity(CurrentFrame).GetAngle() * Math.PI / 180) * 30); }