Darwinbots Forum

Code center => Suggestions => Topic started by: abyaly on April 27, 2006, 10:21:06 PM

Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: abyaly on April 27, 2006, 10:21:06 PM
I was looking through the wiki and though I found refvars for x pos and y pos, I was surprised these werent in there. Since there are no trig functions either, I can't find a way to make bots calculate them accurately.  
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: Numsgil on April 27, 2006, 10:40:37 PM
there is refxpos (http://www.darwinbots.com/WikiManual/index.php?title=.refxpos), is that what you're looking for?

It is possible to emulate sin and cos using numerical approximations.  I did that way back in the day before there was refvel*.
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: abyaly on April 27, 2006, 10:46:45 PM
refxpos gives the x coordinate
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: Numsgil on April 27, 2006, 10:49:02 PM
Yes, and refypos gives the y coordinate.

Is that what you're looking for?
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: abyaly on April 27, 2006, 11:07:05 PM
no. I was looking for the vars in the topic. they dont exist. so I didnt find them
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: Numsgil on April 28, 2006, 11:15:55 AM
No, they don't exist.  But neither does .explode or .becomeagod.  

What is it you would expect the vars in your topic to do?
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: abyaly on April 30, 2006, 05:30:30 PM
Quote from: Numsgil
No, they don't exist.  But neither does .explode or .becomeagod.  

What is it you would expect the vars in your topic to do?
upon thinking this over, I have found reason for those vars not to exist, so never mind ^^
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: EricL on April 30, 2006, 11:05:03 PM
Hey abyaly, pay no attention to Nums.  It's my fault really.  He's a good monkey, but he gets cranky when he's hungry.  I'm supposed to feed him when PY is away, but I forgot....  

The refvars that do exist are mostly just a convienent shortcut to using the memloc/memval pair.  We could add refvars for everything, but that would be a lot of work and double the size of the bot's memory array...
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: Numsgil on April 30, 2006, 11:34:52 PM
I just didn't understand his post.  refdnpos would presumably provide the "down position" of the bot in your eye5.  What is a "down position"?  Is it the distance to the bot expressed as units needed to store in .dn to get to that bot's coordinates?

Anyway, after a little thought, I think you just need to use dist and angle commands.

dist provides the distance to a set of coordinates from where you are now.  angle provides the angle to a set of coordinates from where you are now.
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: abyaly on March 26, 2008, 11:26:28 AM
(warning: old topic)
I propose that the following sysvars be implemented:
.refup - the projection of the distance vector in the direction the bot is facing
.refdx - the "   "    " in the direction 90 degrees to the right
.refdn - the "   "    " in the direction opposite to the one the bot is facing
.refsx - the "   "    " in the direction 90 degrees to the left

Here is an example of how I would like these to work.
I have a bot whose coordinates are (100, 100)
He is looking at a bot that is at (200,200)
My bot is facing direction 0.
.refup would be 100.
.refdx would be 100.
.refdn would be -100
.refsx would be -100

Second example:
I have a bot whose coordinates are (100, 100)
He is looking at a bot that is at (200,200)
He is looking at direction 157.
.refup would be 0.
.refdx would be 141 ~= 100 * root 2
.refdn would be 0.
.refsx would be -141

General case:
I have a bot looking at another bot.
my bot is facing direction a. the angle between my bot and the other bot is b.
z = a - b (the amount of clockwise rotation necessary for my bot to be looking directly at the other bot)
d = the distance between the bots
.refup = d * cos (z)
.refdx = d * sin (z)
.refdn = d * -cos (z)
.refsx = d * -sin (z)
(These figures might not be right; I will check them again when I have more time today)
Title: refdxpos, refuppos, refsxpos, refdnpos
Post by: Numsgil on March 26, 2008, 06:24:18 PM
These would be a good replacement for the current refxpos and refypos.  Express distances in terms of the bots internal frame of reference.