1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Re: maths question about vectors

  1. Feb 5, 2006 #1
    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 cant 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: Feb 5, 2006
  2. jcsd
  3. Feb 5, 2006 #2

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    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.
     
  4. Feb 5, 2006 #3

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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: Feb 5, 2006
  5. Feb 5, 2006 #4

    0rthodontist

    User Avatar
    Science Advisor

    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: Feb 5, 2006
  6. Feb 5, 2006 #5

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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.
     
  7. Feb 5, 2006 #6

    0rthodontist

    User Avatar
    Science Advisor

    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.
     
  8. Feb 5, 2006 #7

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Well, his problem is on a 300x300 grid, so my response was tailored to that, and the presumed grid movement via adjacent squares.
     
  9. Feb 5, 2006 #8

    0rthodontist

    User Avatar
    Science Advisor

    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: Feb 5, 2006
  10. Feb 5, 2006 #9
    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 earths 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: Feb 5, 2006
  11. Feb 15, 2006 #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: Feb 15, 2006
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Re: maths question about vectors
Loading...