private static double CalculatePerfectThrust(Point currentPosition, int dirAngle, Point nextCheckPoint, int nextCheckpointDist, EuclidianVector speedVector) { var maxThrust = 100.0d; if (speedVector == null) { return(maxThrust); } if (dirAngle > 90 || dirAngle < -90) { return(0);//Math.Abs(30 * Math.Sin(EuclidianTools.DegreeToRadian(dirAngle)));; } if (nextCheckpointDist > 1600) { return(100); } var t = Math.Abs(100 * Math.Cos(EuclidianTools.DegreeToRadian(dirAngle))); return((int)t); }
private static Point CalcIdealTarget(int dirAngle, Point nextCheckPoint, Point currentPosition, int distance, EuclidianVector speedV, Dictionary <Point, Point> Targets, bool firstRound) { if (speedV == null) { return(nextCheckPoint); } var referenceVector = new EuclidianVector(100, 0); var dirVector = new EuclidianVector(currentPosition, nextCheckPoint); var angleBetwenReferenceAndDirection = referenceVector.AngleInDegreeWith(dirVector); var angleBetweenReferenceAndSpeed = referenceVector.AngleInDegreeWith(speedV); var angleBetwenDirectionAndSpeed = dirVector.AngleInDegreeWith(speedV); var angleBetwenSpeedAnDir = speedV.AngleInDegreeWith(dirVector); //double offsetAngle = angleBetwenReferenceAndDirection - dirAngle-angleBetwenDirectionAndSpeed; double offsetAngle = angleBetwenReferenceAndDirection - dirAngle - angleBetwenDirectionAndSpeed; // a; Point idealTarget = new Point((int)(nextCheckPoint.X + 300 * Math.Cos(EuclidianTools.DegreeToRadian(offsetAngle))), (int)(nextCheckPoint.Y + 300 * Math.Sin(EuclidianTools.DegreeToRadian(offsetAngle)))); // Point idealTarget = new Point( (int) (nextCheckPoint.X + 400*Math.Cos(EuclidianTools.DegreeToRadian(-angleBetweenReferenceAndSpeed -2*angleBetwenDirectionAndSpeed))), // (int) (nextCheckPoint.Y + 400*Math.Sin(EuclidianTools.DegreeToRadian(-angleBetweenReferenceAndSpeed -2*angleBetwenDirectionAndSpeed)))); Console.Error.WriteLine("dirAngle " + dirAngle); Console.Error.WriteLine("distance " + distance); Console.Error.WriteLine("offsetAngle " + offsetAngle); if (dirAngle > 45 || dirAngle < -45) { return(idealTarget); } /* else * { * * dirVector.Normalise(); * dirVector.ScaleBy(-400); * idealTarget = dirVector.ApplyTo(nextCheckPoint); * * * }*/ if (!firstRound && distance < 1800 && speedV.Norm > 300) { return(Targets[nextCheckPoint]); } return(nextCheckPoint); }
public void DegreeToRadianShouldReturnExpectedValues() { const double PI = Math.PI; Assert.That(EuclidianTools.DegreeToRadian(180), Is.EqualTo(PI)); Assert.That(EuclidianTools.DegreeToRadian(90), Is.EqualTo(PI / 2)); Assert.That(EuclidianTools.DegreeToRadian(270), Is.EqualTo((3 * PI) / 2)); Assert.That(EuclidianTools.DegreeToRadian(225), Is.EqualTo((5 * PI) / 4)); Assert.That(EuclidianTools.DegreeToRadian(360), Is.EqualTo((2 * PI))); }