3
$\begingroup$

I have a vector-valued function and vectors have been drawn with Arrow for visualization purposes.

Clear["Global`*"];
r[t_] := {Sqrt[t], 1/(t - 1), Sin[t]};

ptsCurve = Select[(r[#] & /@ Range[0, 40, 4]), AllTrue[NumericQ]]

Show[ParametricPlot3D[r[t], {t, 0, 40}
  , PlotRangePadding -> Scaled[.15]
  , BoxRatios -> {1, 1, 1}
  , SphericalRegion -> True
  ]
 , Graphics3D[{Red, AbsolutePointSize[6],
   Point /@ ptsCurve
   , Black, Thin, Arrowheads[0.03]
   , Arrow[{{0, 0, 0}, #}, 0.02] & /@ ptsCurve
   }
  ]

enter image description here

Is there an option to improve the rendering of arrowheads? I have seen 276991 but setting Arrowheads size does not help.

I am using v12.2.0 on Win7-x64. This behavior is ever so slightly different on the free cloud account as well.

Thanks for your help in advance.

$\endgroup$
8
  • $\begingroup$ BoxRatios -> {1, 1, 1} affect the arrows. $\endgroup$
    – cvgmt
    Nov 14, 2023 at 5:12
  • $\begingroup$ BoxRatios does not improve the rendering on my system. $\endgroup$
    – Syed
    Nov 14, 2023 at 5:33
  • $\begingroup$ I usually use Arrow@Tube[...,radius] to get nicer looking arrows in 3D. Does that work for you? $\endgroup$
    – Lukas Lang
    Nov 14, 2023 at 7:17
  • 3
    $\begingroup$ Have you tried using one of the symbolic sizes Tiny, Small, Medium or Large? $\endgroup$
    – Carl Woll
    Nov 14, 2023 at 16:38
  • 2
    $\begingroup$ I mean, use something like Arrowheads[Medium] instead of Arrowheads[.03]. $\endgroup$
    – Carl Woll
    Nov 14, 2023 at 16:45

2 Answers 2

4
$\begingroup$

Don't scale to much in the parts of a combined graphics. It's designed for use of primitives by autoscaling. Avoid using 2d graphics primitves, their scaling to 3D is not working as expected by the user.

ptsCurve = Select[(r[#] & /@ Range[0, 40, 4]), AllTrue[NumericQ]];

gr = Graphics3D[{{Red, 
     Opacity[0.4], (Sphere[#, 0.1] &) /@ 
      ptsCurve}, ({Opacity[0.2], RandomColor[], 
        Arrow[Tube[{{0, 0, 0}, #}, 0.03]]} &) /@ ptsCurve}];

pp = ParametricPlot3D[r[t], {t, 0, 40}];

 PolarVector := Function[{r, \[Phi], \[Theta]},
     r {Cos[\[Phi]] Sin[\[Theta]], Sin[\[Phi]] Sin[\[Theta]], 
        Cos[\[Theta]] }]

Now simply combine and chose a view point

  Show[{pp, gr}, ViewPoint -> 
   PolarVector[12, RandomReal[{0, 2 \[Pi]}], 
                    RandomReal[{0,\[Pi]}]], 
      PlotRange -> 5 {{-0.2, 1}, {-0.2, 1}, {-0.20, 1}}]

Curve, points, arrows 3D

$\endgroup$
3
  • $\begingroup$ Thanks for the answer. Can you please say more about the technique used to calculate Viewpoint and also fix syntax. $\endgroup$
    – Syed
    Nov 14, 2023 at 8:35
  • $\begingroup$ This does not answer the original question. For example, when we add BoxRatios->1 . $\endgroup$
    – cvgmt
    Nov 14, 2023 at 9:44
  • 1
    $\begingroup$ Apparently the answer is to write 3D code. After years to combine 2D and 3D rendering, I have given up. Graphics is a branch of art, not the question how to tweak Picassos options to generate a Rodin. $\endgroup$
    – Roland F
    Nov 14, 2023 at 10:13
3
$\begingroup$

Using the function PlotVector3D from the Wolfram Function Repository:

Clear["Global`*"];
r[t_] := {Sqrt[t], 1/(t - 1), Sin[t]};
ptsCurve = Select[(r[#] & /@ Range[0, 40, 4]), AllTrue[NumericQ]]

Show[
 ParametricPlot3D[r[t], {t, 0, 40}
  , PlotRangePadding -> Scaled[.05]
  , BoxRatios -> {1, 1, 1}
  , SphericalRegion -> True
  , ImageSize -> 600
  , PlotRange -> {{0, 6}, {-2, 2}, {-1, 1}}
  ]
 , Graphics3D[{Red, AbsolutePointSize[6],
   Point /@ ptsCurve
   , Red, AbsolutePointSize[12]
   , Point@{0, 0, 0}
   }
  ]
 , PlotVector3D[ptsCurve
  , VectorStyle -> {{Thin, Black}}
  , "ArrowSize" -> Medium]
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ The solution provided by Carl Woll in the comments is based on the documentation (Details section for Arrowheads) that states: The symbolic values Tiny, Small, Medium, and Large can be used for s. With these values, the size of the arrowhead is independent of the total width of the graphic. In the mean time, I discovered the repository function that has additional useful features. $\endgroup$
    – Syed
    Nov 15, 2023 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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