It is currently Fri Sep 21, 2018 12:43 pm Advanced search

which direction is north, south, etc...

Code won't compile? Found a bug? Post here!

which direction is north, south, etc...

Postby mithun » Wed Feb 10, 2010 2:03 pm

Hello guys,

I know this sounds silly, but I went through the original MyTronBot.java file and in the condition for moving North, it checks the location at co ordinate (x,y-1) for a wall. Isn't it supposed to check the co-ordinate at (x,y+1) considering that that co-ordinate is north in a map? ( Totally lost my sense of direction here if you are wondering about the silliness in my question ).

Mithun.
mithun
Cadet
 
Posts: 3
Joined: Wed Feb 10, 2010 1:56 pm

Re: which direction is north, south, etc...

Postby superjhemp » Wed Feb 10, 2010 2:10 pm

The check is correct. Think of the map in x (horizontal) and y (vertical) coordinates, where the origin (0,0) is located at the top-left corner.

writing each point (x,y), the coordinates go as follows:

(0,0) (1,0) (2,0) ... (W-1,0)
(0,1) (1,1) ......... (W-1,1)
(0,2) ...
...
(0,H-1) ............ (W-1,H-1)
superjhemp
Cadet
 
Posts: 7
Joined: Wed Feb 10, 2010 1:09 pm

Re: which direction is north, south, etc...

Postby mithun » Thu Feb 11, 2010 2:25 pm

Thanks dude. I was thinking the origin as bottom left corner.
mithun
Cadet
 
Posts: 3
Joined: Wed Feb 10, 2010 1:56 pm

Re: which direction is north, south, etc...

Postby dutchflyboy » Thu Feb 11, 2010 4:31 pm

You're not the only one. It took me a few hours to understand why my robot was so suicidal.
dutchflyboy
Colonel
 
Posts: 57
Joined: Sun Feb 07, 2010 1:08 am

Re: which direction is north, south, etc...

Postby ntroutman » Thu Feb 11, 2010 11:01 pm

Bottom left origin is normally how we draw Cartesian planes in math class and such. However, for historical on monitors and such the origin is the upper left instead. Its something that gets most people, even those working with graphics a lot, every once in a while.

A similar thing that might throw people off is that the underlying board array is indexed (y, x). To make things easier the Board objects when indexed into take the normal order of (x, y).
ntroutman
Lieutenant
 
Posts: 13
Joined: Wed Feb 10, 2010 6:18 am

Re: which direction is north, south, etc...

Postby mithun » Sun Feb 14, 2010 6:28 pm

lol... I just realised that the plane has also been shifted. i.e. rows are columns and columns are rows....
mithun
Cadet
 
Posts: 3
Joined: Wed Feb 10, 2010 1:56 pm


Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest

cron