This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-10-17 17:43:46

chrisjw
New Scratcher
Registered: 2010-10-17
Posts: 1

Relative angle without point

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  smile

--
Christopher J Williams
Director & Senior scientist - CJWsytemsConsulting.

Offline

 

#2 2010-10-18 01:36:12

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: Relative angle without point

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


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

Board footer