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

Method getStartAngle

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

Source from the content-addressed store, hash-verified

131 }
132
133 private double getStartAngle(double x, double radius)
134 {
135 double angle = 0;
136
137 double startAngleTangent = (polishFunc.evaluateFunction(x+Constants.STEP_SIZE,0,0) - polishFunc.evaluateFunction(x,0,0))/Constants.STEP_SIZE;
138 angle = Math.atan(startAngleTangent);
139
140 double finalX;
141 double error = 10000;
142 for(int i=0; error > Constants.ANGLE_ERROR && i<Constants.MAX_ANGLE_LOOPS; i++)
143 {
144 finalX = x + radius*Math.cos(angle);
145 startAngleTangent = (polishFunc.evaluateFunction(finalX+Constants.STEP_SIZE,0,0) - polishFunc.evaluateFunction(finalX,0,0))/Constants.STEP_SIZE;
146
147 double newAngle = Math.atan(startAngleTangent);
148
149 error = Math.abs(newAngle - angle);
150
151 //System.out.println(angle+" "+newAngle);
152 //System.out.println(x+" "+finalX+" "+radius+"\n");
153
154 angle = newAngle;
155
156
157 }
158
159 return angle;
160 }
161
162 private boolean playerAlreadyHit(int player, int soldier)
163 {

Callers 1

processFunctionRangeMethod · 0.95

Calls 1

evaluateFunctionMethod · 0.45

Tested by

no test coverage detected