MCPcopy Create free account
hub / github.com/catabriga/graphwar / getRK4StartAngle

Method getRK4StartAngle

src/Graphwar/Function.java:311–343  ·  view source on GitHub ↗
(double x, double y, double radius)

Source from the content-addressed store, hash-verified

309 }
310
311 private double getRK4StartAngle(double x, double y, double radius)
312 {
313 double angle = 0;
314 double startAngleTangent;
315 double finalX;
316 double finalY;
317 double error = 10000;
318 for(int i=0; error > Constants.ANGLE_ERROR && i<Constants.MAX_ANGLE_LOOPS; i++)
319 {
320 finalX = x + radius*Math.cos(angle);
321 finalY = y + radius*Math.sin(angle);
322
323 double tempStepSize = Constants.STEP_SIZE;
324
325 double k1 = polishFunc.evaluateFunction( finalX, finalY, 0);
326 double k2 = polishFunc.evaluateFunction( finalX + 0.5*tempStepSize, finalY + 0.5*tempStepSize*k1, 0);
327 double k3 = polishFunc.evaluateFunction( finalX + 0.5*tempStepSize, finalY + 0.5*tempStepSize*k2, 0);
328 double k4 = polishFunc.evaluateFunction( finalX + tempStepSize, finalY + tempStepSize*k3, 0);
329
330 double nextY = finalY + (tempStepSize/6)*(k1 + 2*k2 + 2*k3 + k4);
331 double nextX = finalX + tempStepSize;
332
333 startAngleTangent = (nextY-finalY)/(nextX-finalX);
334
335 double newAngle = Math.atan(startAngleTangent);
336
337 error = Math.abs(newAngle - angle);
338
339 angle = newAngle;
340 }
341
342 return angle;
343 }
344
345 public void processRK4Range(Obstacle obstacle, Player players[], int numPlayers, int currentTurn, boolean inverted)
346 {

Callers 1

processRK4RangeMethod · 0.95

Calls 1

evaluateFunctionMethod · 0.45

Tested by

no test coverage detected