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

#1 2013-04-27 00:51:28

elhamid
New Scratcher
Registered: 2013-04-24
Posts: 1

help with formula

i am new in scratch so how do i do i write down this formula in scribble


dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)*sin(dlat/2) + cos(lat1) * cos(lat2) * sin(dlon/2)*sin(dlon/2)
c = 2 * asin(sqrt(a)))
d = R * c

Offline

 

#2 2013-04-28 02:31:55

Rikihiro
New Scratcher
Registered: 2013-04-24
Posts: 7

Re: help with formula

I'm not a mathematician, but I believe you have to setup a Variable for each element of your formula and give them their initial state of value. Then use the operators to finalize your formula.

Hope this was helpful.

Offline

 

#3 2013-04-29 13:21:55

cauzality
New Scratcher
Registered: 2013-03-19
Posts: 44

Re: help with formula

like rikihero said

instead of " = ", use

set [dlon v] to ((lon2) - (lon1))
i believe all your trig functions should be in the operators "drawer". drag in
([abs v] of [10])
and select your function from the drop down menu

this will end up looking something like this:
when [space v] key pressed
set [halfdlong v] to (((lon2) - (lon1))/[2])
set [halfdlat v] to (((lat2) - (lat1))/[2])
set [a v] to ((([sin v] of (halfdlat))*([sin v] of (halfdlat)))+((([cos v] of (lat1))*([cos v] of (lat2)))*(([sin v] of (halfdlong))*([sin v] of (halfdlong)))))
set [d v] to (([2] * (R)) * ([asin v] of ([sqrt v] of (a))))

Offline

 

Board footer