7
$\begingroup$

Bug introduced in 8.0 and fixed in 10.4 or earlier.


I am a little puzzled by the fact that if I try to use Arrow with Scaled coordinates in 3 dimensions the arrowheads are all over the place. Note Arrow should work with Scaled coordinates as it is mentioned in the relevant documentation. So while this:

pt2D = (Scaled /@ RandomReal[{0, 1}, {2, 2}]);

works fine:

Graphics@{Arrow@#}& @ pt2D

enter image description here

this:

pt3D = (Scaled /@ RandomReal[{0, 1}, {2, 3}]);

gives the arrowhead detached from the arrow:

Graphics3D@{Arrow@#}& @ pt3D

enter image description here

and the same thing happens with Tubed arrows. Here's one from the middle to the edge of a plot:

Show[Plot3D[Sin[x - y], {x, 0, 2 π}, {y, 0, 2 π}, PlotStyle -> Green], 
 Graphics3D[{Arrow[Tube[#]]}& @ {Scaled[{0.5, 0.5, 0.5}],Scaled[{1, 1, 1}]}], ImageSize -> 200]

enter image description here

Is this in any way expected behaviour? If not, can anyone recommend an easy fix?

$\endgroup$
6
  • $\begingroup$ Ok, I can test it now and can confirm this. I do not see how it my be considered expected behaviour imo. $\endgroup$
    – Kuba
    Apr 18, 2014 at 16:10
  • 2
    $\begingroup$ I think this is closely related to an issue I addressed on my web page some time ago. I agree with @Kuba that it's not expected behavior. If you want, I could post the arrow function from my web site as an answer... $\endgroup$
    – Jens
    Apr 18, 2014 at 16:18
  • $\begingroup$ Since we seem to have agreement that this is not the expected behaviour I added the bugs tag. $\endgroup$ Apr 18, 2014 at 16:40
  • $\begingroup$ @Jens ah, I should have looked on your website before asking. If you can find the time that would be great but it's not a pressing issue - I was just puzzled by this. $\endgroup$
    – gpap
    Apr 18, 2014 at 18:02
  • $\begingroup$ @gpap I just added an answer - my own approach was simply to avoid scaled coordinates as much as possible... $\endgroup$
    – Jens
    Apr 18, 2014 at 18:13

1 Answer 1

6
$\begingroup$

This is a bug which seems to be related to the fact that the foreshortening of the arrow is not scaled correctly with the end points of the arrow. The head and shaft of the arrow are treated separately, which may have some benefits (for example, it allows you to independently specify an option Appearance in Arrowheads that determines if the head appears projected in 3D or not). However, in this case, the scaling is out of sync. Strangely, this appears to happen only with the default arrow head.

So the simplest workaround (if you need to use scaled coordinates) is to define a custom arrow head:

Graphics3D[{Arrowheads[{{.01, 1, 
     Graphics3D[Cone[{{0, 0, 0}, {3, 0, 0}}]]}}], 
  Arrow[Tube[Scaled /@ {{0, 0, 0}, {.9, .9, .9}}]]}]

arrow 3d

In 2D, the arrow head is a polygon, and you could use the following:

Graphics3D[{Arrowheads[{{.02, 
     1, {Graphics[
        Polygon[
         {{-1, 1/2}, {1/2, 0}, {-1, -1/2}, {-8/9, 0}, {-1, 1/2}}
        ]], 7/9}}}], 
  Arrow[Scaled /@ {{0, 0, 0}, {.9, .9, .9}}]}]

arrow 2D

$\endgroup$
3
  • 1
    $\begingroup$ Thanks! The reason I am using scaled coordinates is that it's really easier to annotate a plot with them. I have upvoted and plan to accept this. My only reservation is that if the plot range is a bit uneven weird things happen to the arrow head despite the scaling: Show[Plot3D[Sin[(x - y)/40], {x, 0, 30 π}, {y, 0, 30 π}], Graphics3D[{Arrowheads[{{.02, 1, {Graphics[Polygon[{{-1, 1/2}, {1/2, 0}, {-1, -1/2}, {-8/9, 0}, {-1, 1/2}}]], 7/9}}}], Arrow[Scaled /@ {{0, 0, 0}, {.9, .9, .9}}]}]] (this is not to do with your answer, it is happens anyway and is more prevalent with Tube) $\endgroup$
    – gpap
    Apr 19, 2014 at 13:24
  • $\begingroup$ @gpap That's a great example, very entertaining... somebody at Wolfram really should re-think the way arrows wok in 3D. This internal use of Scaled for the heads causes so much headache. $\endgroup$
    – Jens
    Apr 19, 2014 at 16:28
  • $\begingroup$ Yeah, I totally agree. This is entertaining until it becomes annoying methinks. In any case thanks a lot for your help $\endgroup$
    – gpap
    Apr 19, 2014 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.