Deriving an angle from three points
Pierre Sahores
psahores at free.fr
Wed Dec 16 06:58:08 EST 2009
Hi Friends,
Did'nt follow all the present thread so don't know if this can help
but in case, here is the general way i would use to process such
tasks :
on mouseUp
set the style of the templateGraphic to "polygon"
set the opaque of the templateGraphic to "true"
set the filled of the templateGraphic to "true"
set the backgroundcolor of templateGraphic to "blue" # or what
ever color you choose instead
set the textcolor of templateGraphic to "blue" # or what ever
color you choose instead
if there is a grc "new_grc"
then delete grc "new_grc"
create grc "new_grc"
ask "How many sectors do you want to display"
if it is not "" then put it into secteurs_nb
else exit to top
# random example values you will have to replace with the real
values you want to display
put "" into les_valeurs33
repeat with c = 1 to secteurs_nb
put -1+random(2) & return & return after les_valeurs33
end repeat
put char 1 to -3 of les_valeurs33 into les_valeurs33
put -40+the height of this cd into graph_diametre
put graph_diametre div 2 into graph_rayon
put the width of this cd div 2 into x1
put the height of this cd div 2 into y1
put 2*pi / secteurs_nb into langle
put langle / 2 into langlecalcule
repeat with c = 1 to secteurs_nb
put cos((x1*2*pi) + langlecalcule) & "," after the_cos_1
put sin((y1*2*pi) + langlecalcule) & "," after the_sin_1
add langle to langlecalcule
end repeat
put the_cos_1 after the_cos_1
put the_sin_1 after the_sin_1
put pi / secteurs_nb into langle
put "0" into langlecalcule
repeat with c = 1 to 2*secteurs_nb
put cos((x1*2*pi) + langlecalcule) & "," after the_cos_2
put sin((y1*2*pi) + langlecalcule) & "," after the_sin_2
add langle to langlecalcule
end repeat
put the_cos_2 after the_cos_2
put the_sin_2 after the_sin_2
# draw the graphic
set the points of grc "new_grc" to
points_cosin
(secteurs_nb
,les_valeurs33
,x1,y1,the_cos_1,the_sin_1,the_cos_2,the_sin_2,graph_rayon)
end mouseUp
function points_cosin
secteurs_nb
,les_valeurs,x1,y1,the_cos_1,the_sin_1,the_cos_2,the_sin_2,graph_rayon
put "" into points_nb
put "0" into d
repeat with c = 1 to 2*secteurs_nb
put (1 / 11) + ((line c of les_valeurs*10) / 11) into
active_rayon
if c mod 2 = 1 then
add 1 to d
put x1 & "," & y1 & return & round(x1-(item c of
the_cos_2*active_rayon*graph_rayon)),round(y1-(item c of
the_sin_2*active_rayon*graph_rayon)) & return & \
round(x1-(item d of
the_cos_1*active_rayon*graph_rayon)),round(y1-(item d of
the_sin_1*active_rayon*graph_rayon)) & return & \
round(x1-(item 2+c of
the_cos_2*active_rayon*graph_rayon)),round(y1-(item 2+c of
the_sin_2*active_rayon*graph_rayon)) & return after points_nb
else put x1 & "," & y1 & return & round(x1-(item c of
the_cos_2*active_rayon*graph_rayon)),round(y1-(item c of
the_sin_2*active_rayon*graph_rayon)) & return & \
round(x1-(item 2+c of
the_cos_2*active_rayon*graph_rayon)),round(y1-(item 2+c of
the_sin_2*active_rayon*graph_rayon)) & return after points_nb
add 1 to c
end repeat
return points_nb & line 1 of points_nb
end points_cosin
just put this script inside a new stack's button and run it to display
the "new_graph" test graph. Just tested and seems to work fine there.
Have fun !
Pierre
Le 16 déc. 09 à 11:56, Jacques Hausser a écrit :
> I really should re-read my mails before sending them :-(
> I cannot copy and paste scripts directly into mails (I don't know
> why) so I rewrite them... with bugs !
>
> in function calcangle the line
>
> if SurfaceTriangle (a,c,b) then
>
> should be
>
> if SurfaceTriangle(a,c,b) > 0 then
>
> ... but you corrected it already !
>
> Jacques-in-the-moon
>
> ******************************************
> Prof. Jacques Hausser
> Department of Ecology and Evolution
> Biophore / Sorge
> University of Lausanne
> CH 1015 Lausanne
> please use my private address:
> 6 route de Burtigny
> CH-1269 Bassins
> tel/fax: ++ 41 22 366 19 40
> mobile: ++ 41 79 757 05 24
> E-Mail: jacques.hausser at unil.ch
> *******************************************
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
--
Pierre Sahores
mobile : (33) 6 03 95 77 70
www.woooooooords.com
www.sahores-conseil.com
More information about the use-livecode
mailing list