我需要在两个任意“节点”之间绘制箭头。箭头末端需要从四个基本方向之一进入或退出节点:N、S、E、W。
data Dir = N | S | E | W
deriving (Eq, Ord, Show)
cir, circles :: Diagram B
cir = circle 0.3 # showOrigin # lw thick
circles = (cir # named "1") ||| strutX 3 ||| (cir # named "2")
ctrlPoint :: Dir -> V2 Double
ctrlPoint N = r2 (0, 1)
ctrlPoint S = r2 (0, -1)
ctrlPoint E = r2 (1, 0)
ctrlPoint W = r2 (-1, 0)
-- This function should specify an arrow shaft entering nodes from directions dir1 and dir2
shaft :: Dir -> Dir -> Trail V2 Double
shaft dir1 dir2 = trailFromSegments [bézier3 (controlPoint dir1) (controlPoint dir2) (r2 (3, 0))]
example = circles # connect' (with ... & arrowShaft .~ shaft N S ) "1" "2"
在上图中,箭头在第一个圆圈中从北正确进入,在第二个圆圈中从南进入。但是,如果我垂直设置点,一切都会旋转:
circles = (cir # named "1") === strutY 3 === (cir # named "2")
这是不正确的,因为我希望箭头分别从北和南进入。似乎箭头的轴完全旋转了......如何编写我的函数shaft :: Dir -> Dir -> Trail V2 Double
?谢谢