spike
Exemplar
Posts: 360
|
Post by spike on Mar 4, 2011 21:38:56 GMT -5
The distance shown on the map, to waypoints, and in Contracts, is wrong most of the time. Possibly only works when both Y coordinates are positive?? Otherwise usually only gives the X distance, ignoring any Y.
|
|
|
Post by Cory Trese on Mar 4, 2011 22:26:06 GMT -5
I will investigate. The positive and negative numbers are just in the UI, an effect to make De Valtos Prime 1,1
I could use this function but people might complain the number of moves didn't match:
public double distance(Point p, Point q) { double dx = p.x - q.x; //horizontal difference double dy = p.y - q.y; //vertical difference double dist = Math.sqrt( dx*dx + dy*dy ); //distance using Pythagoras theorem return dist; }
|
|
spike
Exemplar
Posts: 360
|
Post by spike on Mar 5, 2011 7:19:02 GMT -5
Thanks. How come it could be different to Pythagoras? Does a diagonal move of one square in ST RPG not take sqrt(2) times as long as a vertical or horizontal move of one square?
Ah ok ST space is not Pythagorean space. Diagonal movement costs the sane as orthogonal. So you need a different formula.
|
|
spike
Exemplar
Posts: 360
|
Post by spike on Mar 5, 2011 7:31:53 GMT -5
Sorry, the distance calc is all fine but I just expected Pythagorean space. ST RPG obviously takes place on the surface of a sphere. Like a planet's oceans. Another hint that the game engine might originally have been called Cannons & Cutlasses? ;-)
|
|