// If the X distance is longer than Y distance, draw from left to right
if($x_dist>$y_dist){
// Draw from left to right
if($from['x']>$to['x']){
$tmpFrom=$from;
$tmpTo=$to;
$from=$tmpTo;
$to=$tmpFrom;
unset($tmp);
}
}else{
// Draw from top to bottom
if($from['y']>$to['y']){
$tmpFrom=$from;
$tmpTo=$to;
$from=$tmpTo;
$to=$tmpFrom;
unset($tmp);
}
}
$angle=1*k($params,'bezier');
// Midpoint between the two ends
$A=[
'x'=>($from['x']+$to['x'])/2,
'y'=>($from['y']+$to['y'])/2
];
// Derived from http://math.stackexchange.com/a/383648 and http://www.wolframalpha.com/input/?i=triangle+%5B1,1%5D+%5B5,2%5D+%5B1-1%2Fsqrt(3),1%2B4%2Fsqrt(3)%5D