I would like to color some lines according to the following color function:
AngleColor[x_] := Module[{
a = ArcCos[{1, 0}.Normalize[x]]/(Pi)},
If[a >= 0.5,
Blend[{White, Orange, Orange, Purple, Purple, White}, 2 (a - 0.5)],
Blend[{White, Purple, Purple, Orange, Orange, White}, 2 a]]]
This function works as intended with the following test data:
testLines = Table[{{0, 0}, {Cos[x], Sin[x]}}, {x, 0, 2 Pi, Pi/600}];
Show[
Graphics[{AngleColor[#[[2]] - #[[1]]], Line[#]}] & /@ testLines,
Background -> Black]
But I dont get the desired result with my real data. Some lines are clearly parallel but have very different colors. Some lines even change color without a change in direction. Any ideas whats going on here?
testD = ToExpression@Import["http://pastebin.com/raw.php?i=jgYKrHNr", "Data"]
Show[
Graphics[{AngleColor[#[[2]] - #[[1]]], Line[#]}] & /@ # & /@ testD,
Background -> Black, ImageSize -> 800]