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
to
lon2
-
lon1

i believe all your trig functions should be in the operators "drawer". drag in
abs
of
10

and select your function from the drop down menu

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

Offline

 

Board footer