2
$\begingroup$

I have a set of data that Line enjoys quite well, however, Tube seems to throw something of a tantrum when I deliver the same set of data. The data:

data = {{-1214.2199935658107`,-848.2705321806565`,-0.00001416666666666664`},{-1244.2463057872262`,-804.5024679750907`,-0.000013333333333333296`},{-1272.6743663132045`,-759.6590618571543`,-0.000012499999999999979`},{-1299.4664556851817`,-713.7981785755134`,-0.000011666666666666634`},{-1324.5865758011587`,-666.978491137754`,-0.000010833333333333317`},{-1348.0004016604767`,-619.2595928877795`,-9.999999999999972`*^-6},{-1369.6752736128424`,-570.7021396907099`,-9.166666666666655`*^-6},{-1389.5802339318311`,-521.3680065458933`,-8.33333333333331`*^-6},{-1407.6861084082525`,-471.32044184944846`,-7.4999999999999655`*^-6},{-1423.9656304860086`,-420.62420257475856`,-6.666666666666648`*^-6},{-1438.3936024494813`,-369.34565482908965`,-5.8333333333333306`*^-6},{-1450.9470855141483`,-317.5528264957635`,-4.999999999999959`*^-6},{-1461.6056085442237`,-265.31540183164884`,-4.1666666666666415`*^-6},{-1470.3513836617653`,-212.70465174468688`,-3.333333333333324`*^-6},{-1477.169516316059`,-159.79329776504858`,-2.4999999999999523`*^-6},{-1482.0481974956165`,-106.65531215558806`,-1.666666666666635`*^-6},{-1484.9788666805996`,-53.3656608828774`,-8.333333333333174`*^-7},{-1485.9563357913094`,-1.0921533706287417`*^-11,0.`},{-1484.9788666806012`,53.36566088285824`,8.333333333333717`*^-7},{-1482.0481974956178`,106.6553121555689`,1.6666666666666891`*^-6},{-1477.1695163160618`,159.79329776502965`,2.5000000000000066`*^-6},{-1470.351383661767`,212.70465174466793`,3.3333333333333782`*^-6},{-1461.6056085442272`,265.3154018316305`,4.166666666666696`*^-6},{-1450.9470855141521`,317.55282649574525`,5.000000000000013`*^-6},{-1438.3936024494853`,369.3456548290715`,5.833333333333385`*^-6},{-1423.9656304860139`,420.62420257474065`,6.666666666666702`*^-6},{-1407.6861084082593`,471.320441849431`,7.50000000000002`*^-6},{-1389.5802339318382`,521.3680065458755`,8.333333333333337`*^-6},{-1369.67527361285`,570.7021396906931`,9.166666666666709`*^-6},{-1348.0004016604855`,619.2595928877626`,0.000010000000000000026`},{-1324.58657580117`,666.9784911377373`,0.000010833333333333344`},{-1299.4664556851928`,713.7981785754989`,0.000011666666666666715`}};

Is inputted into:

Grid[{{Graphics3D[{
     {Darker[Green, 2/3], Thickness[0.01], 
      Arrowheads[{{0.1}}, Appearance -> "Projected"], Arrow[Tube[data]]}
     
     }, AlignmentPoint -> Center, AspectRatio -> Automatic, 
    AutomaticImageSize -> False, Axes -> False, AxesEdge -> None, 
    AxesLabel -> None, AxesOrigin -> {1650.`, -1650.`, -0.00025`}, 
    AxesStyle -> {}, Background -> None, 
    BaselinePosition -> Automatic, BaseStyle -> {}, Boxed -> False, 
    BoxRatios -> {3.2`, 3.2`, 6.5`}, BoxStyle -> {}, 
    ClipPlanes -> None, ClipPlanesStyle -> Automatic, 
    ColorOutput -> Automatic, ContentSelectable -> Automatic, 
    ControllerLinking -> Automatic, ControllerMethod -> Automatic, 
    ControllerPath -> Automatic, CoordinatesToolOptions -> Automatic, 
    DisplayFunction -> Identity, Epilog -> {}, FaceGrids -> None, 
    FaceGridsStyle -> {}, FormatType -> TraditionalForm, 
    ImageMargins -> 0.`, ImagePadding -> All, ImageSize -> 500.`, 
    ImageSizeRaw -> Automatic, LabelStyle -> {}, 
    Lighting -> Automatic, Method -> Automatic, PlotLabel -> None, 
    PlotRange -> {{-2475.`, 
       1815.0000000000002`}, {-1815.0000000000002`, 
       2475.`}, {-0.00032500000000000004`, 0.00032500000000000004`}}, 
    PlotRangePadding -> Automatic, PlotRegion -> Automatic, 
    PreserveImageOptions -> Automatic, Prolog -> {}, 
    RotationAction -> "Fit", SphericalRegion -> True, Ticks -> None, 
    TicksStyle -> {}, TouchscreenAutoZoom -> False, 
    ViewAngle -> 0.33632810973764027`, 
    ViewCenter -> {0.5`, 0.5`, 0.5`}, ViewMatrix -> Automatic, 
    ViewPoint -> {-1.9461497767487252`, 1.477527579217831`, 
      2.340814665690469`}, ViewProjection -> Automatic, 
    ViewRange -> All, ViewVector -> Automatic, 
    ViewVertical -> {0.23556268765910476`, -0.24706981260320413`, 
      0.9399291079028442`}], Graphics3D[{
     {Darker[Green, 2/3], Thickness[0.01], 
      Arrowheads[{{0.1}}, Appearance -> "Projected"], Arrow[Line[data]]}
     
     }, AlignmentPoint -> Center, AspectRatio -> Automatic, 
    AutomaticImageSize -> False, Axes -> False, AxesEdge -> None, 
    AxesLabel -> None, AxesOrigin -> {1650.`, -1650.`, -0.00025`}, 
    AxesStyle -> {}, Background -> None, 
    BaselinePosition -> Automatic, BaseStyle -> {}, Boxed -> False, 
    BoxRatios -> {3.2`, 3.2`, 6.5`}, BoxStyle -> {}, 
    ClipPlanes -> None, ClipPlanesStyle -> Automatic, 
    ColorOutput -> Automatic, ContentSelectable -> Automatic, 
    ControllerLinking -> Automatic, ControllerMethod -> Automatic, 
    ControllerPath -> Automatic, CoordinatesToolOptions -> Automatic, 
    DisplayFunction -> Identity, Epilog -> {}, FaceGrids -> None, 
    FaceGridsStyle -> {}, FormatType -> TraditionalForm, 
    ImageMargins -> 0.`, ImagePadding -> All, ImageSize -> 500.`, 
    ImageSizeRaw -> Automatic, LabelStyle -> {}, 
    Lighting -> Automatic, Method -> Automatic, PlotLabel -> None, 
    PlotRange -> {{-2475.`, 
       1815.0000000000002`}, {-1815.0000000000002`, 
       2475.`}, {-0.00032500000000000004`, 0.00032500000000000004`}}, 
    PlotRangePadding -> Automatic, PlotRegion -> Automatic, 
    PreserveImageOptions -> Automatic, Prolog -> {}, 
    RotationAction -> "Fit", SphericalRegion -> True, Ticks -> None, 
    TicksStyle -> {}, TouchscreenAutoZoom -> False, 
    ViewAngle -> 0.33632810973764027`, 
    ViewCenter -> {0.5`, 0.5`, 0.5`}, ViewMatrix -> Automatic, 
    ViewPoint -> {-1.9461497767487252`, 1.477527579217831`, 
      2.340814665690469`}, ViewProjection -> Automatic, 
    ViewRange -> All, ViewVector -> Automatic, 
    ViewVertical -> {0.23556268765910476`, -0.24706981260320413`, 
      0.9399291079028442`}]}}]

Which gives: Plot of the provided data showing problem with Tube versus Line

Why does Tube treat this set of data so much differently than Line? What can be done to make Tube work as expected?

Scaling does nothing to fix this issue.

$\endgroup$
3
  • $\begingroup$ It seems like your choice of 'BoxRatios' is causing your problem. Try removing it and things seem to appear normal $\endgroup$ – Dunlop Feb 26 '20 at 20:07
  • $\begingroup$ @Dunlop that would be unfortunate as this is part of a much larger graphic. I don’t understand why that would be the issue, though. It seems to be ignoring the z-axis part of the data, within Tube. That also doesn’t give any insight as to why Line is successful. I will see what happens. $\endgroup$ – CA Trevillian Feb 26 '20 at 20:10
  • 3
    $\begingroup$ @CATrevillian Line is successful because it has no three-dimensional thickness. $\endgroup$ – kirma Feb 26 '20 at 20:18
2
$\begingroup$

This problem can be vastly simplified. It involves BoxRatios, the fact that your data is essentially flat, and you are forcing it to a non-flat form factor which will scale the Tube to be very non-circular. Consider the following:

With[{data = {{0, 0, 0}, {1, 1, 0.001}}},
 Grid[{{
    Graphics3D[Arrow[Tube[data]], BoxRatios -> {1, 1, 1}], 
    Graphics3D[Arrow[Line[data]], BoxRatios -> {1, 1, 1}]}}]]

enter image description here

Your arrow has become essentially a wall as the tube has been stretched on the z axis. Without forced ratios it's flat, but much more sensible:

With[{data = {{0, 0, 0}, {1, 1, 0.001}}},
 Grid[{{
    Graphics3D[Arrow[Tube[data]]],
    Graphics3D[Arrow[Line[data]]]}}]]

enter image description here

You can play tricks with your data and Tubes, though:

Module[{
  data = {{0, 0, 0}, {1, 1, 0.001}},
  boxratios = {1, 1, 1},
  plotrange, scaling},
 plotrange = CoordinateBounds@data;
 scaling = boxratios/(#2 - #1 & @@@ plotrange);
 Grid[{{
    Graphics3D[
     Scale[Arrow[Tube[ScalingTransform[scaling]@data]], 1/scaling, {0, 0, 0}],
     PlotRange -> plotrange, BoxRatios -> boxratios],
    Graphics3D[Arrow[Line[data]],
     PlotRange -> plotrange, BoxRatios -> boxratios]}}]]

enter image description here

If you know both your PlotRange and BoxRatios you can compensate for these things with some ease:

Here the "flat" data is first stretched with ScalingTransform to 1:1:1 form factor, then the tubed arrow graphics primitive is created, and then graphics primitives are Scaled back to flat form - which is again stretched to shape of a cube with BoxRatios...

$\endgroup$
6
  • $\begingroup$ So the use of Tube here is then unfeasible? How can Tube be made to work with this scale? I use the BoxRatios to enhance the difference to combat the flatness. As I experienced, even scaling the z axis did not fix the issue, though the BoxRatios remained in use then. Unfortunately, the BoxRatios are seemingly important. Perhaps scaling the z axis will fix the need for them, so I will try this. $\endgroup$ – CA Trevillian Feb 26 '20 at 20:20
  • 1
    $\begingroup$ @CATrevillian I added a hint on how one can start working around this. $\endgroup$ – kirma Feb 26 '20 at 20:35
  • $\begingroup$ Cool, that works for one set of data, but when you introduce another that has the same flatness, they get pushed to either side of the box...I don't know then if the issue is with ScalingTransformation or Scale. You can't seem to wrap Scale around multiple primitives. This is the "middle" of a larger set of data, made slightly larger in the x and y. Each works separately with the scaling method, but to plot them together creates the edge localization of the flat curves on either side of the box. FIXED IT! $\endgroup$ – CA Trevillian Feb 26 '20 at 21:07
  • 1
    $\begingroup$ @CATrevillian They were related to Scale. I tried to improve the answer a bit. $\endgroup$ – kirma Feb 26 '20 at 21:11
  • 1
    $\begingroup$ @CA This works when you put in the correct syntax! Now, to properly color it....and scale everything else ;S Wunderbar! Bellissimo! $\endgroup$ – CA Trevillian Feb 26 '20 at 21:12

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.