Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
Ok, I can test it now and can confirm this. I do not see how it my be considered expected behaviour imo. –  Kuba Apr 18 at 16:10
2  
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... –  Jens Apr 18 at 16:18
    
Since we seem to have agreement that this is not the expected behaviour I added the bugs tag. –  Sjoerd C. de Vries Apr 18 at 16:40
    
@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. –  gpap Apr 18 at 18:02
    
@gpap I just added an answer - my own approach was simply to avoid scaled coordinates as much as possible... –  Jens Apr 18 at 18:13

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
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) –  gpap Apr 19 at 13:24
    
@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. –  Jens Apr 19 at 16:28
    
Yeah, I totally agree. This is entertaining until it becomes annoying methinks. In any case thanks a lot for your help –  gpap Apr 19 at 18:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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