Changeset 647a312 in galcon-client for src/com/example/helloandroid/Fleet.java
- Timestamp:
- Jun 6, 2010, 2:50:25 AM (14 years ago)
- Branches:
- master
- Children:
- 012e702, 04a9a00, 69f6f01
- Parents:
- 730d808
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/example/helloandroid/Fleet.java
r730d808 r647a312 21 21 private boolean isNextToAPlanet; 22 22 private boolean isClockwise; 23 24 private boolean done;25 23 26 24 /* Optimising: pre-calculate paths */ 27 25 public Fleet(Planet source, Planet destination, int numShips, int faction) { 28 done = false;29 30 26 source.setNumShips(source.getNumShips()-numShips); 31 27 … … 213 209 } 214 210 215 //double radAngle = Math.atan(getSlope(destination.getX(), destination.getY(), dblX, dblY)); 216 //figure out which way to go clockwise or counter clockwise 217 tangentAngle = (Math.atan(getSlope(nearPlanet.getX(),nearPlanet.getY(),dblX,dblY))) + (Math.PI/2); 218 angle = Math.atan((Math.tan(tangentAngle) - Math.tan(direction))/(1 + Math.tan(tangentAngle)*Math.tan(direction))); 219 220 Log.d("Galcon", "tangentAngle: "+tangentAngle); 221 Log.d("Galcon", "direction: "+direction+", angle: "+angle); 222 223 if (angle <= Math.PI/2) 224 angle = Math.PI - angle; 225 226 //double diff = direction-angle; 227 228 //if(diff > 0) 211 tangentAngle = Math.atan(getSlope(nearPlanet.getX(),nearPlanet.getY(),dblX,dblY)); 212 213 if(dblX < nearPlanet.getX()) 214 tangentAngle += Math.PI; 215 216 tangentAngle += Math.PI/2; 217 229 218 if(Math.abs(tangentAngle-direction) > Math.PI/2) { 230 219 isClockwise = false; … … 240 229 241 230 isNextToAPlanet = true; 242 //figure out which way to go clockwise or counter clockwise243 /*tangentDirection = (Math.atan(getSlope(temp.getX(),temp.getY(),dblX,dblY))) + (Math.PI/2);244 angle = Math.atan((Math.tan(tangentDirection) - Math.tan(direction))/(1 + Math.tan(tangentDirection)*Math.tan(direction)));245 if (angle <= Math.PI/2)246 angle = Math.PI - angle;*/247 //get next point and the direction and set it248 231 } 249 232 } else { … … 253 236 254 237 double dist = Math.abs(destination.getY() - (Math.tan(direction)*destination.getX()) - xIntercept)/(double)Math.sqrt(Math.pow(direction,2)+1); 255 //Log.d("Galcon", "dist: "+dist); 256 if(dist < 5 && dist == 1){ 238 if(dist < 2){ 257 239 dblY += (Math.sin(direction)*speed); 258 240 dblX += (Math.cos(direction)*speed); … … 267 249 } else { 268 250 angle = speed/(double)nearPlanet.radius*.1; 269 270 if(!done) {271 Log.d("Galcon", "direction: "+direction+", angle: "+angle);272 Log.d("Galcon", "original: ("+dblX+", "+dblY+")");273 }274 251 275 252 if(isClockwise){ … … 282 259 direction = direction - angle; 283 260 } 284 285 if(!done)286 Log.d("Galcon", "new: ("+dblX+", "+dblY+")");287 288 done = true;289 261 290 262 x = (int)dblX;
Note:
See TracChangeset
for help on using the changeset viewer.