Re: maths question about vectors

  • Thread starter Thread starter Schrodinger's Dog
  • Start date Start date
  • Tags Tags
    Vectors
Click For Summary

Homework Help Overview

The discussion revolves around programming a method to determine if a ship has circumnavigated a globe or map within a computer game, specifically using coordinates on a grid. The problem involves defining what "circumnavigate" means in this context, particularly considering the constraints of avoiding poles and land masses.

Discussion Character

  • Exploratory, Conceptual clarification, Problem interpretation

Approaches and Questions Raised

  • Participants explore various methods to track the ship's movement across a grid, including defining boundaries and using coordinates to determine if the ship has returned to its starting longitude. There are discussions on whether to use logical expressions or cumulative vectors to assess circumnavigation.

Discussion Status

Several participants have offered different strategies for tracking the ship's position, including maintaining westernmost and easternmost coordinates. There is ongoing exploration of the implications of movement types, such as discrete versus continuous movement, and how these affect the circumnavigation check.

Contextual Notes

Participants note the importance of defining terms clearly, such as "circumnavigate," and the potential complications introduced by teleportation or uneven movement. The discussion also highlights the constraints of a 300x300 grid and the need for efficient memory usage in programming solutions.

Schrodinger's Dog
Messages
840
Reaction score
7
OK I have a computer game and I need a method of programming in for any given map, proof that I have cirumnavigated the globe let's say the range is in co-ordinates 0,0 to 300,300 or 90,000 squares. How can I prove that Unit 1 or U1 has passed from say point a at (grenwich mean) GM or whatever arbitrary start line of longitude say a1 and back to a point at the line of longitude a1? This isn't a homework question it refers to a particular computer game.

I guess what I'm asking is can you program a mathematical expression which will give a 1 or 0 answer to has the ship circumnavigated the globe/map, assume you can't cross the poles and any method requires going round continents and land masses?

Is this possible or not?

Assume the data set for using the equation is every point that the ship passes through either in a diferential form dx/dy= derived from the data set as a whole, or as a set of all the points of the ships passage either is fine. If I apply the equation with logical espressions consistent with say C++ or some sort of maths language, to the data set would I get a 0 or 1 answer using logical expressions or is this just not possible?
 
Last edited:
Physics news on Phys.org
The first thing you will have to do is decide what YOU mean by "circumnavigate". Strictly speaking, it would mean go in a great circle around the Earth but "dodging" continents you can't do that. What normally is required (the Whitbread race for example) is that you must pass through every longitude and pass through (or within a certain distance of) The diametrically opposite point to your starting point.
If you measure latitude, "Lat", in degrees from +90 N of the equator to -90 S of the equator and longitude, "Long", from 0 to 360 degrees then the "diametrically opposite point" has latitude -Lat and longitude 360- Long.
 
Trying to fix CivIV, eh? :smile:

You could just attach to each ship the westernmost x-coordinate W and the easternmost x-coordinate E it has ever occupied. When it is at W, and moves west, you decrement W. (And wrap it around, if necessary) Similarly if the ship is at E and goes east.

If, in doing so, W = E, then the ship has circumnavigated the world.

A less efficient way would be to store at each x-coordinate "yes" or "no" depending on if the ship has ever been at that coordinate. When they're all "yes", the ship has circumnavigated the world.

(The two are slightly different: the former, Going from 0->299 and then back to 0 circumnavigates. the latter, going from 0->299 is enough to circumnavigate)
 
Last edited:
With Hurkyl's method also remember to start W and E at slightly different coordinates, else you would have circumnavigated the world without moving.

Also, all of this assumes "no teleportation." If you allow teleporting then it can become ambiguous.
 
Last edited:
Or, more subtlely, you don't check for W==E until you update their values!

I suppose you could make my two ideas equivalent if you check for

(W+1)%300 == E

and then you don't have the subtle issue cropping up either.
 
I still think you should start out with them being different. Doing otherwise leaves room for bugs. For example, what if the ship moves north with a very slight western bearing but not enough to show as a different coordinate?
For the same reason I think it shouldn't be motion triggered but rather by checking whether the ship is closer to W or to E. This would also cover the teleportation issue and any issues with terrain/unit hopping that sometimes occur. It would leave an issue when it comes to drawing the W and E together at the very end--you could say something like "1 degree is close enough" to get around that.
 
Well, his problem is on a 300x300 grid, so my response was tailored to that, and the presumed grid movement via adjacent squares.
 
You're right, I edited out that comment. There's no reason to assume the unit moves in discrete squares, though. If it moves continuously then you have the added challenge of figuring which square the unit came from last to figure the direction of motion, which is not otherwise necessary.

Edit: though actually that is probably not a very great challenge, but I still think that motion-based detection is more trouble than it's worth because movement can be uneven due to collisions/teleports/unit location conflicts.
 
Last edited:
Precisely 300x300 grid: Thankyou all, luckily it's that easy then, each move is one square precisely and each unit can move 1-3 squares. I came up with the answer myself that each NW movement means -1 each W movement means -1 and each SW movement = -1 each S or N movement =0 each NE Movement =+1 and each E movement=+1 and each SE movement=+1. This means if you take the map size and apply that logic say the map is size 100 then any value of +101 or -101 assuming you go directly or at least partialy directly from W to E or vice a versa you will have an answer, +100 or greater =circumnavigation and -100 or greater= circumnavigation.

What I'm wondering is if there's a diferential way of doing the same thing: I.e. using moves to have a cumualtive vector diferential which is precisely what the +1 -1 is in my example, but in another form. I'm thinking obviously you can, but am I right? Now let's say there are no squares and we're talking about the Earth's surface with all the vagueries that invovles, can we judge someone as having circumnavigated the globe from GPS or whatever data set you want to use?
 
Last edited:
  • #10
Yes hurkyl the fact that you can circumnavigate the globe without ever using a ship to do so is annoying. So I hoped to provide those damn beta testers with a way to do it without costing to much memory. How did you guess? Anyway I told 'em my method which just as memory intensive as the other one; whether they'll include something so minor in a computer game is anyones guess. Thanks for the Answer I'm sure the beta testers were happy you could help :) after all they work hard for their money, i.e nothing.:smile:
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 16 ·
Replies
16
Views
13K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
2K
  • · Replies 13 ·
Replies
13
Views
4K