Message Boards Message Boards

Draw a ParametricPlot3D space curve as an arrow?

GROUPS:

I have a space curve created by ParametricPlot3D. Something like:

plot = ParametricPlot3D[{Sin[u], Cos[u], u/(2*Pi)}, {u, 0, 2*Pi}, 
   Axes -> None, ImageSize -> Medium];`

To turn that into an arrow, I use:

plotA = plot /. Line -> Arrow;

and can then display that plotA properly as an arrow by Show or Print.

But now I have to customize the arrow heads, e.g. use something like

Arrowheads[Small]

I can find no way to bring that into my plotA-arrow-curve. It seems that Arrowheads cannot be used as a Directive or Option for Show or the like. Instead it has to precede all Arrow graphics primitives. Probably I have to use a more intelligent form of the Replace-statement above. But I cannot find a legal form for replacing "Line" in plot by "Arrowheads[Small],Arrow" for plotA.

In any case I think that Replace-method is some kind of brute force for drawing a parametric curve as an arrow. Are there better ways?

POSTED BY: Werner Geiger
Answer
3 months ago

You just need to remember that graphics primitives are scoped within lists. In addition, operate you pattern matching on larger parts, rather then the Line head. Now that you know these two little details, you can modify it as you will. Look at the small modification I added below

plotA = plot /. Line[x_] -> {Arrowheads[0.075], Red, Arrow[x]}

best

yehuda

POSTED BY: Yehuda Ben-Shimol
Answer
3 months ago

Great, Yehuda. Thanks a lot.

This works. Obviously I am still not experienced with pattern replacing.

POSTED BY: Werner Geiger
Answer
3 months ago

You could also make a replica of ParametricPlot3D yourself:

data = Table[{Sin[u], Cos[u], u/(2*Pi)}, {u, 0, 2 Pi, 0.01}];
Graphics3D[{Arrowheads[Small], Arrow[data]}]
POSTED BY: Sander Huisman
Answer
3 months ago

Thanks Sander, I knew that. But this is not the same as a ParametricPlot. It is just a fixed sequence of Line/Arrow-Segments.

POSTED BY: Werner Geiger
Answer
3 months ago

It is nearly identical as what ParametricPlot outputs, there is not much magic going on... The main difference is the adaptive refinement...

POSTED BY: Sander Huisman
Answer
3 months ago

Ja, of course. But I feel to need that adaptive refinement.

The background of my question is, that I have to draw 3D arcs for angles between vectors within large and complex graphics created from many objects and rotation transformations. Hence I do not really want to determine myself, how many segments would be reasonable for each and every angle-arc.

Basically the problem is, that there is nothing like Circle with From/To-Angles for 3D. Hence this must be constructed manually with ParametricPlot3D.

POSTED BY: Werner Geiger
Answer
3 months ago

There is:

https://mathematica.stackexchange.com/questions/10957/an-efficient-circular-arc-primitive-for-graphics3d

It uses b-splines in a very efficient way, and uses far less points as ParametricPlot3D, moreover, it should be faster.

POSTED BY: Sander Huisman
Answer
3 months ago

Whow! Thanks.

This looks great. But will cost me days for understanding the code. :-)

POSTED BY: Werner Geiger
Answer
3 months ago

You can have a look at the free package CurvesGraphics6 http://www.dimi.uniud.it/gorni/Mma

POSTED BY: Gianluca Gorni
Answer
3 months ago

Isn't it a kind of overkill to use some huge package just für drawing a circle arc in 3D?

POSTED BY: Werner Geiger
Answer
3 months ago

Yes, it's overkill if that is your one and only need. However, sometimes you don't know you need something until you realize you can do it. Advertizers think this way. Yesterday I was pointed out a glaring bug in the package. It's fixed now.

POSTED BY: Gianluca Gorni
Answer
3 months ago

Group Abstract Group Abstract