Graphing random points on the XY-plane












6












$begingroup$


I am trying to generate around 10-20 points on the xy- plane in the domain $[-10,10]times[-10,10]$ (in 3D) and I am having trouble. I want to draw the plane in 3D, graph the random (they do not have to be random but at least nicely dispersed) points, and then graph vertical lines through these points. I found this How to generate random points in a region? and tried to adopt it for a plane in 3D but since i am very new to Mathematica I cannot seem to make it work. I am aware of the RandomPoint command but the problem is i need to describe the region and I do not know how to describe the region of xy-plane. I tried z=0 but I think it only accepts "worded" regions.



Any help would be appreciated.










share|improve this question











$endgroup$












  • $begingroup$
    If you want to use RandomPoint, there's ImplicitRegion: RandomPoint[ ImplicitRegion[Abs@x < 10 && Abs@y < 10 && z == 0, {x, y, z}], 100] will give you 100 points in the specified region. Alternatively, you could also generate points in 2D using RandomReal[10,{100,2}] and add the z coordinate using Append[0]/@pts
    $endgroup$
    – Lukas Lang
    Mar 5 at 17:22


















6












$begingroup$


I am trying to generate around 10-20 points on the xy- plane in the domain $[-10,10]times[-10,10]$ (in 3D) and I am having trouble. I want to draw the plane in 3D, graph the random (they do not have to be random but at least nicely dispersed) points, and then graph vertical lines through these points. I found this How to generate random points in a region? and tried to adopt it for a plane in 3D but since i am very new to Mathematica I cannot seem to make it work. I am aware of the RandomPoint command but the problem is i need to describe the region and I do not know how to describe the region of xy-plane. I tried z=0 but I think it only accepts "worded" regions.



Any help would be appreciated.










share|improve this question











$endgroup$












  • $begingroup$
    If you want to use RandomPoint, there's ImplicitRegion: RandomPoint[ ImplicitRegion[Abs@x < 10 && Abs@y < 10 && z == 0, {x, y, z}], 100] will give you 100 points in the specified region. Alternatively, you could also generate points in 2D using RandomReal[10,{100,2}] and add the z coordinate using Append[0]/@pts
    $endgroup$
    – Lukas Lang
    Mar 5 at 17:22
















6












6








6





$begingroup$


I am trying to generate around 10-20 points on the xy- plane in the domain $[-10,10]times[-10,10]$ (in 3D) and I am having trouble. I want to draw the plane in 3D, graph the random (they do not have to be random but at least nicely dispersed) points, and then graph vertical lines through these points. I found this How to generate random points in a region? and tried to adopt it for a plane in 3D but since i am very new to Mathematica I cannot seem to make it work. I am aware of the RandomPoint command but the problem is i need to describe the region and I do not know how to describe the region of xy-plane. I tried z=0 but I think it only accepts "worded" regions.



Any help would be appreciated.










share|improve this question











$endgroup$




I am trying to generate around 10-20 points on the xy- plane in the domain $[-10,10]times[-10,10]$ (in 3D) and I am having trouble. I want to draw the plane in 3D, graph the random (they do not have to be random but at least nicely dispersed) points, and then graph vertical lines through these points. I found this How to generate random points in a region? and tried to adopt it for a plane in 3D but since i am very new to Mathematica I cannot seem to make it work. I am aware of the RandomPoint command but the problem is i need to describe the region and I do not know how to describe the region of xy-plane. I tried z=0 but I think it only accepts "worded" regions.



Any help would be appreciated.







plotting graphics3d random






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 5 at 18:32









m_goldberg

87.4k872198




87.4k872198










asked Mar 5 at 17:14









SorfoshSorfosh

1403




1403












  • $begingroup$
    If you want to use RandomPoint, there's ImplicitRegion: RandomPoint[ ImplicitRegion[Abs@x < 10 && Abs@y < 10 && z == 0, {x, y, z}], 100] will give you 100 points in the specified region. Alternatively, you could also generate points in 2D using RandomReal[10,{100,2}] and add the z coordinate using Append[0]/@pts
    $endgroup$
    – Lukas Lang
    Mar 5 at 17:22




















  • $begingroup$
    If you want to use RandomPoint, there's ImplicitRegion: RandomPoint[ ImplicitRegion[Abs@x < 10 && Abs@y < 10 && z == 0, {x, y, z}], 100] will give you 100 points in the specified region. Alternatively, you could also generate points in 2D using RandomReal[10,{100,2}] and add the z coordinate using Append[0]/@pts
    $endgroup$
    – Lukas Lang
    Mar 5 at 17:22


















$begingroup$
If you want to use RandomPoint, there's ImplicitRegion: RandomPoint[ ImplicitRegion[Abs@x < 10 && Abs@y < 10 && z == 0, {x, y, z}], 100] will give you 100 points in the specified region. Alternatively, you could also generate points in 2D using RandomReal[10,{100,2}] and add the z coordinate using Append[0]/@pts
$endgroup$
– Lukas Lang
Mar 5 at 17:22






$begingroup$
If you want to use RandomPoint, there's ImplicitRegion: RandomPoint[ ImplicitRegion[Abs@x < 10 && Abs@y < 10 && z == 0, {x, y, z}], 100] will give you 100 points in the specified region. Alternatively, you could also generate points in 2D using RandomReal[10,{100,2}] and add the z coordinate using Append[0]/@pts
$endgroup$
– Lukas Lang
Mar 5 at 17:22












2 Answers
2






active

oldest

votes


















9












$begingroup$

You can use RandomPoint with InfinitePlane and draw lines using InfiniteLine:



plane = InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}];
pts = RandomPoint[plane, 20, {{-10, 10}, {-10, 10}, {0, 0}}];

Graphics3D[{plane, Red, InfiniteLine[#, {0, 0, 1}] & /@ pts, Blue,
Sphere[pts, .1]}, PlotRange -> {{-10, 10}, {-10, 10}, {-5, 5}}]


enter image description here






share|improve this answer











$endgroup$













  • $begingroup$
    Wow, that is perfect. Now if i wanted to change the direction vector of the line depending on the points, how would i do that? I tried changing ${0,0,1}$ to ${#[[2]], #[[1]], sqrt[#[[2]]^2 + #[[1]]^2]}$ but that didn't work.
    $endgroup$
    – Sorfosh
    Mar 5 at 19:18








  • 1




    $begingroup$
    @Sorfosh it works fine to me. Did you type sqrt instead Sqrt ?
    $endgroup$
    – halmir
    Mar 5 at 20:23










  • $begingroup$
    oh... wow. I forgot it is case sensitive. Thank you! :P
    $endgroup$
    – Sorfosh
    Mar 5 at 21:41



















3












$begingroup$

Maybe this will work for you.



First define a function for generating $n$ random points on the xy-plane.



pts[n_] := {#1, #2, 0} & @@@ RandomReal[{-10., 10.}, {n, 2}]


Then



SeedRandom[42];
Module[{n = 20, p0} ,
p0 = pts[n];
Graphics3D[
{{AbsolutePointSize[4], Point[p0]},
{Red, Thick, HalfLine[#, {0, 0, 1}] & /@ p0}},
PlotRange -> {{-10, 10}, {-10, 10}, {0, 10}}]]


plot






share|improve this answer











$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    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%2f192670%2fgraphing-random-points-on-the-xy-plane%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









    9












    $begingroup$

    You can use RandomPoint with InfinitePlane and draw lines using InfiniteLine:



    plane = InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}];
    pts = RandomPoint[plane, 20, {{-10, 10}, {-10, 10}, {0, 0}}];

    Graphics3D[{plane, Red, InfiniteLine[#, {0, 0, 1}] & /@ pts, Blue,
    Sphere[pts, .1]}, PlotRange -> {{-10, 10}, {-10, 10}, {-5, 5}}]


    enter image description here






    share|improve this answer











    $endgroup$













    • $begingroup$
      Wow, that is perfect. Now if i wanted to change the direction vector of the line depending on the points, how would i do that? I tried changing ${0,0,1}$ to ${#[[2]], #[[1]], sqrt[#[[2]]^2 + #[[1]]^2]}$ but that didn't work.
      $endgroup$
      – Sorfosh
      Mar 5 at 19:18








    • 1




      $begingroup$
      @Sorfosh it works fine to me. Did you type sqrt instead Sqrt ?
      $endgroup$
      – halmir
      Mar 5 at 20:23










    • $begingroup$
      oh... wow. I forgot it is case sensitive. Thank you! :P
      $endgroup$
      – Sorfosh
      Mar 5 at 21:41
















    9












    $begingroup$

    You can use RandomPoint with InfinitePlane and draw lines using InfiniteLine:



    plane = InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}];
    pts = RandomPoint[plane, 20, {{-10, 10}, {-10, 10}, {0, 0}}];

    Graphics3D[{plane, Red, InfiniteLine[#, {0, 0, 1}] & /@ pts, Blue,
    Sphere[pts, .1]}, PlotRange -> {{-10, 10}, {-10, 10}, {-5, 5}}]


    enter image description here






    share|improve this answer











    $endgroup$













    • $begingroup$
      Wow, that is perfect. Now if i wanted to change the direction vector of the line depending on the points, how would i do that? I tried changing ${0,0,1}$ to ${#[[2]], #[[1]], sqrt[#[[2]]^2 + #[[1]]^2]}$ but that didn't work.
      $endgroup$
      – Sorfosh
      Mar 5 at 19:18








    • 1




      $begingroup$
      @Sorfosh it works fine to me. Did you type sqrt instead Sqrt ?
      $endgroup$
      – halmir
      Mar 5 at 20:23










    • $begingroup$
      oh... wow. I forgot it is case sensitive. Thank you! :P
      $endgroup$
      – Sorfosh
      Mar 5 at 21:41














    9












    9








    9





    $begingroup$

    You can use RandomPoint with InfinitePlane and draw lines using InfiniteLine:



    plane = InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}];
    pts = RandomPoint[plane, 20, {{-10, 10}, {-10, 10}, {0, 0}}];

    Graphics3D[{plane, Red, InfiniteLine[#, {0, 0, 1}] & /@ pts, Blue,
    Sphere[pts, .1]}, PlotRange -> {{-10, 10}, {-10, 10}, {-5, 5}}]


    enter image description here






    share|improve this answer











    $endgroup$



    You can use RandomPoint with InfinitePlane and draw lines using InfiniteLine:



    plane = InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}];
    pts = RandomPoint[plane, 20, {{-10, 10}, {-10, 10}, {0, 0}}];

    Graphics3D[{plane, Red, InfiniteLine[#, {0, 0, 1}] & /@ pts, Blue,
    Sphere[pts, .1]}, PlotRange -> {{-10, 10}, {-10, 10}, {-5, 5}}]


    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 5 at 17:53

























    answered Mar 5 at 17:37









    halmirhalmir

    10.5k2544




    10.5k2544












    • $begingroup$
      Wow, that is perfect. Now if i wanted to change the direction vector of the line depending on the points, how would i do that? I tried changing ${0,0,1}$ to ${#[[2]], #[[1]], sqrt[#[[2]]^2 + #[[1]]^2]}$ but that didn't work.
      $endgroup$
      – Sorfosh
      Mar 5 at 19:18








    • 1




      $begingroup$
      @Sorfosh it works fine to me. Did you type sqrt instead Sqrt ?
      $endgroup$
      – halmir
      Mar 5 at 20:23










    • $begingroup$
      oh... wow. I forgot it is case sensitive. Thank you! :P
      $endgroup$
      – Sorfosh
      Mar 5 at 21:41


















    • $begingroup$
      Wow, that is perfect. Now if i wanted to change the direction vector of the line depending on the points, how would i do that? I tried changing ${0,0,1}$ to ${#[[2]], #[[1]], sqrt[#[[2]]^2 + #[[1]]^2]}$ but that didn't work.
      $endgroup$
      – Sorfosh
      Mar 5 at 19:18








    • 1




      $begingroup$
      @Sorfosh it works fine to me. Did you type sqrt instead Sqrt ?
      $endgroup$
      – halmir
      Mar 5 at 20:23










    • $begingroup$
      oh... wow. I forgot it is case sensitive. Thank you! :P
      $endgroup$
      – Sorfosh
      Mar 5 at 21:41
















    $begingroup$
    Wow, that is perfect. Now if i wanted to change the direction vector of the line depending on the points, how would i do that? I tried changing ${0,0,1}$ to ${#[[2]], #[[1]], sqrt[#[[2]]^2 + #[[1]]^2]}$ but that didn't work.
    $endgroup$
    – Sorfosh
    Mar 5 at 19:18






    $begingroup$
    Wow, that is perfect. Now if i wanted to change the direction vector of the line depending on the points, how would i do that? I tried changing ${0,0,1}$ to ${#[[2]], #[[1]], sqrt[#[[2]]^2 + #[[1]]^2]}$ but that didn't work.
    $endgroup$
    – Sorfosh
    Mar 5 at 19:18






    1




    1




    $begingroup$
    @Sorfosh it works fine to me. Did you type sqrt instead Sqrt ?
    $endgroup$
    – halmir
    Mar 5 at 20:23




    $begingroup$
    @Sorfosh it works fine to me. Did you type sqrt instead Sqrt ?
    $endgroup$
    – halmir
    Mar 5 at 20:23












    $begingroup$
    oh... wow. I forgot it is case sensitive. Thank you! :P
    $endgroup$
    – Sorfosh
    Mar 5 at 21:41




    $begingroup$
    oh... wow. I forgot it is case sensitive. Thank you! :P
    $endgroup$
    – Sorfosh
    Mar 5 at 21:41











    3












    $begingroup$

    Maybe this will work for you.



    First define a function for generating $n$ random points on the xy-plane.



    pts[n_] := {#1, #2, 0} & @@@ RandomReal[{-10., 10.}, {n, 2}]


    Then



    SeedRandom[42];
    Module[{n = 20, p0} ,
    p0 = pts[n];
    Graphics3D[
    {{AbsolutePointSize[4], Point[p0]},
    {Red, Thick, HalfLine[#, {0, 0, 1}] & /@ p0}},
    PlotRange -> {{-10, 10}, {-10, 10}, {0, 10}}]]


    plot






    share|improve this answer











    $endgroup$


















      3












      $begingroup$

      Maybe this will work for you.



      First define a function for generating $n$ random points on the xy-plane.



      pts[n_] := {#1, #2, 0} & @@@ RandomReal[{-10., 10.}, {n, 2}]


      Then



      SeedRandom[42];
      Module[{n = 20, p0} ,
      p0 = pts[n];
      Graphics3D[
      {{AbsolutePointSize[4], Point[p0]},
      {Red, Thick, HalfLine[#, {0, 0, 1}] & /@ p0}},
      PlotRange -> {{-10, 10}, {-10, 10}, {0, 10}}]]


      plot






      share|improve this answer











      $endgroup$
















        3












        3








        3





        $begingroup$

        Maybe this will work for you.



        First define a function for generating $n$ random points on the xy-plane.



        pts[n_] := {#1, #2, 0} & @@@ RandomReal[{-10., 10.}, {n, 2}]


        Then



        SeedRandom[42];
        Module[{n = 20, p0} ,
        p0 = pts[n];
        Graphics3D[
        {{AbsolutePointSize[4], Point[p0]},
        {Red, Thick, HalfLine[#, {0, 0, 1}] & /@ p0}},
        PlotRange -> {{-10, 10}, {-10, 10}, {0, 10}}]]


        plot






        share|improve this answer











        $endgroup$



        Maybe this will work for you.



        First define a function for generating $n$ random points on the xy-plane.



        pts[n_] := {#1, #2, 0} & @@@ RandomReal[{-10., 10.}, {n, 2}]


        Then



        SeedRandom[42];
        Module[{n = 20, p0} ,
        p0 = pts[n];
        Graphics3D[
        {{AbsolutePointSize[4], Point[p0]},
        {Red, Thick, HalfLine[#, {0, 0, 1}] & /@ p0}},
        PlotRange -> {{-10, 10}, {-10, 10}, {0, 10}}]]


        plot







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 5 at 18:25

























        answered Mar 5 at 17:39









        m_goldbergm_goldberg

        87.4k872198




        87.4k872198






























            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%2f192670%2fgraphing-random-points-on-the-xy-plane%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

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?