
y1=!random -0.3*$rg,-0.95*$rg
y2=!random max(0,$y1+0.75*$rg),0.95*$rg
y3=!random min(0,$y2-0.75*$rg),-0.95*$rg
y4=!random max(0.3*$rg,$y3+0.75*$rg),0.95*$rg

:redo1
x1=!random -0.75*$rg, 0
!for check in $taken3
 !if abs($x1-$check)<0.1*$rg
  !goto redo1
 !endif
!next check

:redo2
x2=!random max(0,$x1+0.4*$rg),0.75*$rg
!for check in $taken3
 !if abs($x2-$check)<0.1*$rg
  !goto redo1
 !endif
!next check

taken3=$x1,$x2

slope1=$[($y2-$y1)/($x1+$rg)]
slope2=$[($y3-$y2)/($x2-$x1)]
slope3=$[($y4-$y3)/($rg-$x2)]
cst=$[$y1-$slope1*(-$rg)-$slope2*$x1-$slope3*$x2]

f=!rawmath $slope1*min(t,$x1)+$slope2*max(min(t,$x2),$x1)+$slope3*max(t,$x2)+$cst

