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

#1 2012-07-20 00:24:09

game99999
Scratcher
Registered: 2009-12-05
Posts: 28

Angle calculation

I need a script that would make it so whenever a sprite hits a surface it calculates the angle of the surface, please tell me asap. (:


^you have no idea how long that took to type^^^^^^^^^^^^^

Offline

 

#2 2012-07-20 06:11:23

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Angle calculation

That's quite hard. You basically want to find a tangent to a given surface, right? Well, the solution is to find two points close together on the surface, and use them, plus some trig, to find the angle.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#3 2012-07-20 10:58:06

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Angle calculation

Hardmath's right. This is very hard to achieve. There is, however, a method of switching to a 1px costume and pointing in direction 0 delete all of vals, repeat 360 move 1 step, if touching (edge) add [1] to [vals v], move -1 steps, turn right 1 degree

You'll need to put that script after repeat 360 360 times in a row O.O

Then, it's all trig from there.  smile


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&display=small

Offline

 

#4 2012-07-20 12:23:11

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Angle calculation

Well, depending on the accuracy, you could make do in 20-ish repetitions.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

Board footer