MetaPost random numbers question
Hello everyone - I have created a custom symbol for a broken stalagmite/stalactite. It is exactly the same as regular stalactite/stalagmite (also custom code) except turned on its side. I could use the orientation feature to simply turn the stalagmite symbol, but then it is not called out in the legend. I would like to have the code randomly point the symbol either left or right. My code uses the "uniformdeviate()" function to generate random numbers which are then tested. The problem is that the symbols point left far more often than right. I suspect the way I am using uniformdeviate is not right. I would appreciate someone getting an eyeball on my code to see if it at least sane. Code is below ... I have tried both "uniformdeviate(1)" and "uniformdeviate 1", with basically the same result. Both syntaxes compile without error. The very few samples I found while searching use both syntaxes. I found precious little in any of the MetaPost documentation about this function. Thanks! -- =============== Bill Gee # This code defines the broken stal symbol. def p_u_brokenstal (expr pos,theta,sc,al) = U:=(0.2u, 0.4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; #Draw and paint the symbol. Point randomly left or right if uniformdeviate(1) < 0.5: thfill (0.4u,0.2u)--(-0.4u,0.0u)--(0.4u,-0.2u)--cycle; else: thfill (-0.4u,0.2u)--(0.4u,0.0u)--(-0.4u,-0.2u)--cycle; fi enddef;
participants (1)
-
Bill Gee