Open discoleo opened 2 years ago
The Double-Lined Arrowhead can now be easily composed using 2 helper functions:
# Double Lined ArrowHead: --->> # - a high-level helper function; arrH2 = function(x, y, slope, d=-1, dV=c(d, -d)) { # Shift point along line: arrHead = list(arrHS(x, y, slope=slope, d = dV)); # Double Arrow p2 = shiftPoint(c(x, y), slope=slope, d = - d); arrHead2 = list(arrHS(p2[1], p2[2], slope=slope, d = dV)); arrHead = c(arrHead, arrHead2); return(arrHead); } # Double Lined Head arrowDH = function(x, y, d=0.2, lwd=1, d.head=-1, h.lwd=lwd, col="red", asD=FALSE) { slope = compute_slope(x, y); xylist = function(x, y) list(list(x=x, y=y)); ### ArrowTail if(asD) { arrow = shiftLine(x, y, d = c(d, -d), slope=slope); arrow = list(arrow, lwd=lwd); } else { arrow = xylist(x, y); arrow = c(arrow, lwd = lwd); } ### Head arrHead = arrH2(x[2], y[2], slope=slope, d=d, dV=d.head); arrHead$lwd = h.lwd; ### Full Arrow lst = list(Arrow=arrow, Head=arrHead); class(lst) = c("arrow", "list"); # Plot lines: print("Finished") lines(lst, col=col); invisible(lst); }
Particularly solved for the following input:
plot.base() x = c(0, 6); y = c(1, 6); arrowDH(x, y, d=-0.2, lwd=2);
Plot view:
The Double-Lined Arrowhead can now be easily composed using 2 helper functions: