Hi,
A first post in the forums and a first upload - please be gentle!
My daughter and I are currently using scratch to model some robotics path choosing and collision avoidance routines. One of the key features in this is the ability to iteratively scan all nearby objects and plot an active avoidance arc-path rather than bumping off them. To do this you need to know where an object is in relation to you while some distance away.
Distance is easy - but relative angles while moving is more difficult. Basic scratch functions allow you to get an angle to an object by pointing at it, but if you are currently moving you have to stop to do this. What is needed is the ability to scan around you without pointing.
Ive seen a few examples of using the Atan maths function to give a relative angle between two objects without having to use the point command - but all the ones I have seen are incomplete or wrong. (apologies if you have published one which is right - Ive not found it yet!)
Based on this, Ive written a very quick test which uses the ATAN (ArcTangent) maths function to calculate relative angles between two objects which takes into account the 0,0 location at screen center which makes life a tad more tircky. (The same code should work for any two points on the screen regaurdless of direction etc)
See - http://scratch.mit.edu/projects/chrisjw/1359517
Hope you find it useful
--
Christopher J Williams
Director & Senior scientist - CJWsytemsConsulting.
Offline
Yeah I know of this issue. I made something like this a while ago.
http://scratch.mit.edu/projects/what-the/1178312 mine points to xy but you can remove the point to block.
Download script here http://resources.scratchr.org/view/125
My site Offline