Extracting points from 3D plot that lie along an arbitrarily oriented lineHow to properly project a Graphics...

Why is the air gap between the stator and rotor on a motor kept as small as it is?

Addressing unnecessary daily meetings with manager?

Are there any balance issues in allowing two half-feats to be taken without the Ability Score Increase instead of a feat?

How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?

Can the Mage Hand cantrip be used to trip an enemy who is running away?

Integer Lists of Noah

The tensor product of two monoidal categories

Received a dinner invitation through my employer's email, is it ok to attend?

Some interesting calculation puzzle that I made

Is a request to book a business flight ticket for a graduate student an unreasonable one?

Why did Harry Potter get a bedroom?

Is there a strong legal guarantee that the U.S. can give to another country that it won't attack them?

Fast validation of time windows in a routing problem

What is this little owl-like bird?

This one's for Matthew:

Was I subtly told to resign?

How were Martello towers supposed to work?

Optimization terminology: "Exact" v. "Approximate"

Print the last, middle and first character of your code

Does Lufthansa weigh your carry on luggage?

Confirming the Identity of a (Friendly) Reviewer After the Reviews

Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?

Why isn't pressure filtration popular compared to vacuum filtration?

How do native German speakers usually express skepticism (using even) about a premise?



Extracting points from 3D plot that lie along an arbitrarily oriented line


How to properly project a Graphics object consisting of line primitivesMapping Contour Plot onto ListPlot3D (or by using color variations)Region projection of multivariable interpolated functionParticle moving on curve which is the intersection of a surface and a planeRendering ListPlot3D SurfaceAnimate a circle “rolling” along a complicated 3D curveListPlot with a histogram of values on the vertical axisFinding optimal points in contours produced by ListContourPlotFinding average of attributed linesListPlot3D label is covered by surface in combined graphic






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







5












$begingroup$


Starting from i.e. the following 3d plot:



d = RandomReal[1, {100, 3}];
ListPlot3D[d]


Is it possible to extract points that lay along an arbitrarily oriented line, i.e. like this:



Show[{ListPlot3D[d], Graphics3D[Line[{{0, -.5, 1}, {0.5, 1, 1}}]]}]


?



EDIT: Z values of the plot along the line projected onto the x-y plane










share|improve this question











$endgroup$












  • $begingroup$
    Can you clarify a little, are you looking for the points that exactly intersect that line, or the z values of the plot along the line projected onto the x-y plane?
    $endgroup$
    – N.J.Evans
    8 hours ago










  • $begingroup$
    z values of the plot along the line projected onto the x-y plane
    $endgroup$
    – ATomek
    8 hours ago


















5












$begingroup$


Starting from i.e. the following 3d plot:



d = RandomReal[1, {100, 3}];
ListPlot3D[d]


Is it possible to extract points that lay along an arbitrarily oriented line, i.e. like this:



Show[{ListPlot3D[d], Graphics3D[Line[{{0, -.5, 1}, {0.5, 1, 1}}]]}]


?



EDIT: Z values of the plot along the line projected onto the x-y plane










share|improve this question











$endgroup$












  • $begingroup$
    Can you clarify a little, are you looking for the points that exactly intersect that line, or the z values of the plot along the line projected onto the x-y plane?
    $endgroup$
    – N.J.Evans
    8 hours ago










  • $begingroup$
    z values of the plot along the line projected onto the x-y plane
    $endgroup$
    – ATomek
    8 hours ago














5












5








5


1



$begingroup$


Starting from i.e. the following 3d plot:



d = RandomReal[1, {100, 3}];
ListPlot3D[d]


Is it possible to extract points that lay along an arbitrarily oriented line, i.e. like this:



Show[{ListPlot3D[d], Graphics3D[Line[{{0, -.5, 1}, {0.5, 1, 1}}]]}]


?



EDIT: Z values of the plot along the line projected onto the x-y plane










share|improve this question











$endgroup$




Starting from i.e. the following 3d plot:



d = RandomReal[1, {100, 3}];
ListPlot3D[d]


Is it possible to extract points that lay along an arbitrarily oriented line, i.e. like this:



Show[{ListPlot3D[d], Graphics3D[Line[{{0, -.5, 1}, {0.5, 1, 1}}]]}]


?



EDIT: Z values of the plot along the line projected onto the x-y plane







plotting list-manipulation graphics3d mesh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago









MelaGo

2,0161 gold badge1 silver badge7 bronze badges




2,0161 gold badge1 silver badge7 bronze badges










asked 9 hours ago









ATomekATomek

1098 bronze badges




1098 bronze badges












  • $begingroup$
    Can you clarify a little, are you looking for the points that exactly intersect that line, or the z values of the plot along the line projected onto the x-y plane?
    $endgroup$
    – N.J.Evans
    8 hours ago










  • $begingroup$
    z values of the plot along the line projected onto the x-y plane
    $endgroup$
    – ATomek
    8 hours ago


















  • $begingroup$
    Can you clarify a little, are you looking for the points that exactly intersect that line, or the z values of the plot along the line projected onto the x-y plane?
    $endgroup$
    – N.J.Evans
    8 hours ago










  • $begingroup$
    z values of the plot along the line projected onto the x-y plane
    $endgroup$
    – ATomek
    8 hours ago
















$begingroup$
Can you clarify a little, are you looking for the points that exactly intersect that line, or the z values of the plot along the line projected onto the x-y plane?
$endgroup$
– N.J.Evans
8 hours ago




$begingroup$
Can you clarify a little, are you looking for the points that exactly intersect that line, or the z values of the plot along the line projected onto the x-y plane?
$endgroup$
– N.J.Evans
8 hours ago












$begingroup$
z values of the plot along the line projected onto the x-y plane
$endgroup$
– ATomek
8 hours ago




$begingroup$
z values of the plot along the line projected onto the x-y plane
$endgroup$
– ATomek
8 hours ago










2 Answers
2






active

oldest

votes


















5












$begingroup$

SeedRandom[5]
d = RandomReal[1, {100, 3}];


You can use -.5 + 3 # - #2 & (or Function[{x, y}, -.5 + 3 x - y]) as the setting for MeshFunctions in ListPlot3D:



Show[lp3d = ListPlot3D[d, MeshFunctions -> {-.5 + 3 # - #2 &}, 
Mesh -> {{0}}, MeshStyle -> Directive[Red, Thick], BoundaryStyle -> None],
Graphics3D[{Thick , Blue, Line[{{0, -.5, 1}, {0.5, 1, 1}}],
Opacity[.5, Yellow], EdgeForm @ None,
InfinitePlane[{{0, -.5, 0}, {0, -.5, 1}, {0.5, 1, 1}}]}]]


enter image description here



To extract the points on the red line:



Cases[Normal @ lp3d, Line[x_] :> x, All][[1]]



{{0.492655, 0.977959, 0.559503}, {0.491386, 0.973947,
   0.484116}, {0.477966, 0.933211, 0.303948}, {0.476062, 0.92816,
   0.451244}, {0.459746, 0.878862, 0.640324}, {0.457492,
0.872273,
   0.586974}, {0.454029, 0.861943, 0.568448}, {0.441994,
0.825895,
   0.39336}, {0.396855, 0.690417, 0.20754}, {0.395551, 0.686462,
   0.255852}, {0.392548, 0.677572, 0.17963}, {0.350269, 0.550753,
   0.612022}, {0.341512, 0.524435, 0.760695}, {0.313441,
0.440292,
   0.52727}, {0.304016, 0.411343, 0.164743}, {0.300216, 0.400556,
   0.123016}, {0.293312, 0.379549, 0.431375}, {0.279583, 0.33874,
   0.571648}, {0.267421, 0.302245, 0.850239}, {0.266698,
0.299818,
   0.85685}, {0.226072, 0.177329, 0.737677}, {0.217928, 0.152775,
   0.650557}, {0.192837, 0.0784445, 0.831587}, {0.187349,
0.0619587,
   0.854096}, {0.174868, 0.024533, 0.602241}}







share|improve this answer











$endgroup$





















    1












    $begingroup$

    You can use the interpolation that ListPlot uses, which you can then evaluate at any point on the line (within the domain of the interpolation):



    zFN = Interpolation[d, InterpolationOrder -> 1, 
    "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}];

    ClearAll[xyline, zSect];
    xyline[x_] = {(1 - 2 x), 2 x}.{{0, -.5}, {0.5, 1}};
    zSect[x_] := zFN @@ xyline[x];

    zSect[0.25] (* test a value *)
    (* 0.654833 *)

    Show[
    ListPlot3D[d],
    ParametricPlot3D[Append[xyline[x], zSect[x]], {x, 0, 1}]
    ]


    enter image description here






    share|improve this answer









    $endgroup$
















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "387"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201815%2fextracting-points-from-3d-plot-that-lie-along-an-arbitrarily-oriented-line%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5












      $begingroup$

      SeedRandom[5]
      d = RandomReal[1, {100, 3}];


      You can use -.5 + 3 # - #2 & (or Function[{x, y}, -.5 + 3 x - y]) as the setting for MeshFunctions in ListPlot3D:



      Show[lp3d = ListPlot3D[d, MeshFunctions -> {-.5 + 3 # - #2 &}, 
      Mesh -> {{0}}, MeshStyle -> Directive[Red, Thick], BoundaryStyle -> None],
      Graphics3D[{Thick , Blue, Line[{{0, -.5, 1}, {0.5, 1, 1}}],
      Opacity[.5, Yellow], EdgeForm @ None,
      InfinitePlane[{{0, -.5, 0}, {0, -.5, 1}, {0.5, 1, 1}}]}]]


      enter image description here



      To extract the points on the red line:



      Cases[Normal @ lp3d, Line[x_] :> x, All][[1]]



      {{0.492655, 0.977959, 0.559503}, {0.491386, 0.973947,
         0.484116}, {0.477966, 0.933211, 0.303948}, {0.476062, 0.92816,
         0.451244}, {0.459746, 0.878862, 0.640324}, {0.457492,
      0.872273,
         0.586974}, {0.454029, 0.861943, 0.568448}, {0.441994,
      0.825895,
         0.39336}, {0.396855, 0.690417, 0.20754}, {0.395551, 0.686462,
         0.255852}, {0.392548, 0.677572, 0.17963}, {0.350269, 0.550753,
         0.612022}, {0.341512, 0.524435, 0.760695}, {0.313441,
      0.440292,
         0.52727}, {0.304016, 0.411343, 0.164743}, {0.300216, 0.400556,
         0.123016}, {0.293312, 0.379549, 0.431375}, {0.279583, 0.33874,
         0.571648}, {0.267421, 0.302245, 0.850239}, {0.266698,
      0.299818,
         0.85685}, {0.226072, 0.177329, 0.737677}, {0.217928, 0.152775,
         0.650557}, {0.192837, 0.0784445, 0.831587}, {0.187349,
      0.0619587,
         0.854096}, {0.174868, 0.024533, 0.602241}}







      share|improve this answer











      $endgroup$


















        5












        $begingroup$

        SeedRandom[5]
        d = RandomReal[1, {100, 3}];


        You can use -.5 + 3 # - #2 & (or Function[{x, y}, -.5 + 3 x - y]) as the setting for MeshFunctions in ListPlot3D:



        Show[lp3d = ListPlot3D[d, MeshFunctions -> {-.5 + 3 # - #2 &}, 
        Mesh -> {{0}}, MeshStyle -> Directive[Red, Thick], BoundaryStyle -> None],
        Graphics3D[{Thick , Blue, Line[{{0, -.5, 1}, {0.5, 1, 1}}],
        Opacity[.5, Yellow], EdgeForm @ None,
        InfinitePlane[{{0, -.5, 0}, {0, -.5, 1}, {0.5, 1, 1}}]}]]


        enter image description here



        To extract the points on the red line:



        Cases[Normal @ lp3d, Line[x_] :> x, All][[1]]



        {{0.492655, 0.977959, 0.559503}, {0.491386, 0.973947,
           0.484116}, {0.477966, 0.933211, 0.303948}, {0.476062, 0.92816,
           0.451244}, {0.459746, 0.878862, 0.640324}, {0.457492,
        0.872273,
           0.586974}, {0.454029, 0.861943, 0.568448}, {0.441994,
        0.825895,
           0.39336}, {0.396855, 0.690417, 0.20754}, {0.395551, 0.686462,
           0.255852}, {0.392548, 0.677572, 0.17963}, {0.350269, 0.550753,
           0.612022}, {0.341512, 0.524435, 0.760695}, {0.313441,
        0.440292,
           0.52727}, {0.304016, 0.411343, 0.164743}, {0.300216, 0.400556,
           0.123016}, {0.293312, 0.379549, 0.431375}, {0.279583, 0.33874,
           0.571648}, {0.267421, 0.302245, 0.850239}, {0.266698,
        0.299818,
           0.85685}, {0.226072, 0.177329, 0.737677}, {0.217928, 0.152775,
           0.650557}, {0.192837, 0.0784445, 0.831587}, {0.187349,
        0.0619587,
           0.854096}, {0.174868, 0.024533, 0.602241}}







        share|improve this answer











        $endgroup$
















          5












          5








          5





          $begingroup$

          SeedRandom[5]
          d = RandomReal[1, {100, 3}];


          You can use -.5 + 3 # - #2 & (or Function[{x, y}, -.5 + 3 x - y]) as the setting for MeshFunctions in ListPlot3D:



          Show[lp3d = ListPlot3D[d, MeshFunctions -> {-.5 + 3 # - #2 &}, 
          Mesh -> {{0}}, MeshStyle -> Directive[Red, Thick], BoundaryStyle -> None],
          Graphics3D[{Thick , Blue, Line[{{0, -.5, 1}, {0.5, 1, 1}}],
          Opacity[.5, Yellow], EdgeForm @ None,
          InfinitePlane[{{0, -.5, 0}, {0, -.5, 1}, {0.5, 1, 1}}]}]]


          enter image description here



          To extract the points on the red line:



          Cases[Normal @ lp3d, Line[x_] :> x, All][[1]]



          {{0.492655, 0.977959, 0.559503}, {0.491386, 0.973947,
             0.484116}, {0.477966, 0.933211, 0.303948}, {0.476062, 0.92816,
             0.451244}, {0.459746, 0.878862, 0.640324}, {0.457492,
          0.872273,
             0.586974}, {0.454029, 0.861943, 0.568448}, {0.441994,
          0.825895,
             0.39336}, {0.396855, 0.690417, 0.20754}, {0.395551, 0.686462,
             0.255852}, {0.392548, 0.677572, 0.17963}, {0.350269, 0.550753,
             0.612022}, {0.341512, 0.524435, 0.760695}, {0.313441,
          0.440292,
             0.52727}, {0.304016, 0.411343, 0.164743}, {0.300216, 0.400556,
             0.123016}, {0.293312, 0.379549, 0.431375}, {0.279583, 0.33874,
             0.571648}, {0.267421, 0.302245, 0.850239}, {0.266698,
          0.299818,
             0.85685}, {0.226072, 0.177329, 0.737677}, {0.217928, 0.152775,
             0.650557}, {0.192837, 0.0784445, 0.831587}, {0.187349,
          0.0619587,
             0.854096}, {0.174868, 0.024533, 0.602241}}







          share|improve this answer











          $endgroup$



          SeedRandom[5]
          d = RandomReal[1, {100, 3}];


          You can use -.5 + 3 # - #2 & (or Function[{x, y}, -.5 + 3 x - y]) as the setting for MeshFunctions in ListPlot3D:



          Show[lp3d = ListPlot3D[d, MeshFunctions -> {-.5 + 3 # - #2 &}, 
          Mesh -> {{0}}, MeshStyle -> Directive[Red, Thick], BoundaryStyle -> None],
          Graphics3D[{Thick , Blue, Line[{{0, -.5, 1}, {0.5, 1, 1}}],
          Opacity[.5, Yellow], EdgeForm @ None,
          InfinitePlane[{{0, -.5, 0}, {0, -.5, 1}, {0.5, 1, 1}}]}]]


          enter image description here



          To extract the points on the red line:



          Cases[Normal @ lp3d, Line[x_] :> x, All][[1]]



          {{0.492655, 0.977959, 0.559503}, {0.491386, 0.973947,
             0.484116}, {0.477966, 0.933211, 0.303948}, {0.476062, 0.92816,
             0.451244}, {0.459746, 0.878862, 0.640324}, {0.457492,
          0.872273,
             0.586974}, {0.454029, 0.861943, 0.568448}, {0.441994,
          0.825895,
             0.39336}, {0.396855, 0.690417, 0.20754}, {0.395551, 0.686462,
             0.255852}, {0.392548, 0.677572, 0.17963}, {0.350269, 0.550753,
             0.612022}, {0.341512, 0.524435, 0.760695}, {0.313441,
          0.440292,
             0.52727}, {0.304016, 0.411343, 0.164743}, {0.300216, 0.400556,
             0.123016}, {0.293312, 0.379549, 0.431375}, {0.279583, 0.33874,
             0.571648}, {0.267421, 0.302245, 0.850239}, {0.266698,
          0.299818,
             0.85685}, {0.226072, 0.177329, 0.737677}, {0.217928, 0.152775,
             0.650557}, {0.192837, 0.0784445, 0.831587}, {0.187349,
          0.0619587,
             0.854096}, {0.174868, 0.024533, 0.602241}}








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 8 hours ago

























          answered 8 hours ago









          kglrkglr

          204k10 gold badges233 silver badges463 bronze badges




          204k10 gold badges233 silver badges463 bronze badges

























              1












              $begingroup$

              You can use the interpolation that ListPlot uses, which you can then evaluate at any point on the line (within the domain of the interpolation):



              zFN = Interpolation[d, InterpolationOrder -> 1, 
              "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}];

              ClearAll[xyline, zSect];
              xyline[x_] = {(1 - 2 x), 2 x}.{{0, -.5}, {0.5, 1}};
              zSect[x_] := zFN @@ xyline[x];

              zSect[0.25] (* test a value *)
              (* 0.654833 *)

              Show[
              ListPlot3D[d],
              ParametricPlot3D[Append[xyline[x], zSect[x]], {x, 0, 1}]
              ]


              enter image description here






              share|improve this answer









              $endgroup$


















                1












                $begingroup$

                You can use the interpolation that ListPlot uses, which you can then evaluate at any point on the line (within the domain of the interpolation):



                zFN = Interpolation[d, InterpolationOrder -> 1, 
                "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}];

                ClearAll[xyline, zSect];
                xyline[x_] = {(1 - 2 x), 2 x}.{{0, -.5}, {0.5, 1}};
                zSect[x_] := zFN @@ xyline[x];

                zSect[0.25] (* test a value *)
                (* 0.654833 *)

                Show[
                ListPlot3D[d],
                ParametricPlot3D[Append[xyline[x], zSect[x]], {x, 0, 1}]
                ]


                enter image description here






                share|improve this answer









                $endgroup$
















                  1












                  1








                  1





                  $begingroup$

                  You can use the interpolation that ListPlot uses, which you can then evaluate at any point on the line (within the domain of the interpolation):



                  zFN = Interpolation[d, InterpolationOrder -> 1, 
                  "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}];

                  ClearAll[xyline, zSect];
                  xyline[x_] = {(1 - 2 x), 2 x}.{{0, -.5}, {0.5, 1}};
                  zSect[x_] := zFN @@ xyline[x];

                  zSect[0.25] (* test a value *)
                  (* 0.654833 *)

                  Show[
                  ListPlot3D[d],
                  ParametricPlot3D[Append[xyline[x], zSect[x]], {x, 0, 1}]
                  ]


                  enter image description here






                  share|improve this answer









                  $endgroup$



                  You can use the interpolation that ListPlot uses, which you can then evaluate at any point on the line (within the domain of the interpolation):



                  zFN = Interpolation[d, InterpolationOrder -> 1, 
                  "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}];

                  ClearAll[xyline, zSect];
                  xyline[x_] = {(1 - 2 x), 2 x}.{{0, -.5}, {0.5, 1}};
                  zSect[x_] := zFN @@ xyline[x];

                  zSect[0.25] (* test a value *)
                  (* 0.654833 *)

                  Show[
                  ListPlot3D[d],
                  ParametricPlot3D[Append[xyline[x], zSect[x]], {x, 0, 1}]
                  ]


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Michael E2Michael E2

                  155k12 gold badges213 silver badges502 bronze badges




                  155k12 gold badges213 silver badges502 bronze badges






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Mathematica Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201815%2fextracting-points-from-3d-plot-that-lie-along-an-arbitrarily-oriented-line%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                      Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                      Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...