Re: maths question about vectors

  • Thread starter Schrodinger's Dog
  • Start date
  • Tags
    Vectors
In summary, the game asks for a way to 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. 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.
  • #1
Schrodinger's Dog
835
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
  • #2
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.
 
  • #3
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:
  • #4
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:
  • #5
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.
 
  • #6
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.
 
  • #7
Well, his problem is on a 300x300 grid, so my response was tailored to that, and the presumed grid movement via adjacent squares.
 
  • #8
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:
  • #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 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:

FAQ: Re: maths question about vectors

What are vectors in mathematics?

Vectors in mathematics are quantities that have both magnitude (size) and direction. They are represented by arrows pointing in a specific direction, with the length of the arrow representing the magnitude of the vector.

How are vectors used in real life?

Vectors are used in many different real-life applications, such as in physics, engineering, and navigation. They can be used to represent forces, velocities, and directions in various systems.

What is the difference between a scalar and a vector?

A scalar is a quantity that only has magnitude, such as temperature or mass. A vector, on the other hand, has both magnitude and direction. Scalars can be added or subtracted using basic arithmetic, while vectors require more complex operations.

How are vectors represented in mathematics?

In mathematics, vectors are typically represented using coordinates or components. This involves breaking down the vector into its horizontal and vertical components, which can then be represented using numbers or variables.

What are some common operations performed on vectors?

Some common operations performed on vectors include addition, subtraction, scalar multiplication, and vector multiplication (such as dot product and cross product). These operations are used to manipulate vectors and solve mathematical problems involving them.

Similar threads

Replies
1
Views
1K
Replies
1
Views
1K
Replies
3
Views
1K
Replies
5
Views
1K
Replies
4
Views
3K
Replies
13
Views
2K
Replies
19
Views
4K
Replies
41
Views
4K
Back
Top