How to check if a point lies withing a 4-point polygon (in 3d space)












1














In the $x,y,z$ space, I want to check if a point lies within a polygon. The $z$ coordinates for the vertices of the will not change, but will do for the point for which we're checking. How can I check this? I have attached an image which might make it a bit clearer



enter image description here










share|cite|improve this question





























    1














    In the $x,y,z$ space, I want to check if a point lies within a polygon. The $z$ coordinates for the vertices of the will not change, but will do for the point for which we're checking. How can I check this? I have attached an image which might make it a bit clearer



    enter image description here










    share|cite|improve this question



























      1












      1








      1







      In the $x,y,z$ space, I want to check if a point lies within a polygon. The $z$ coordinates for the vertices of the will not change, but will do for the point for which we're checking. How can I check this? I have attached an image which might make it a bit clearer



      enter image description here










      share|cite|improve this question















      In the $x,y,z$ space, I want to check if a point lies within a polygon. The $z$ coordinates for the vertices of the will not change, but will do for the point for which we're checking. How can I check this? I have attached an image which might make it a bit clearer



      enter image description here







      vector-spaces vectors






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Dec 4 '18 at 21:30









      Andrei

      11.4k21026




      11.4k21026










      asked Dec 4 '18 at 20:57









      AvagantamoAvagantamo

      142




      142






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The first thing you want to check is that your point, let's call it $P$, lies in the plane of polygon $ABCD$. You can use vectors and cross products for this step. You know that any three points form a plane. You can describe this plane by the normal to the plane. $$vec n_{PAB}propto (vec P-vec A)times(vec P-vec B)$$
          If the cross product is zero, it means that $P$ lies on the $AB$ line, and all you need to check if it is between $A$ and $B$. For that, use scalar product: $$ (vec P-vec A)cdot(vec P-vec B)$$
          If the scalar product is $0$, $P=A$ or $P=B$. If the scalar product is negative, the points is between the two, otherwise is outside. In this last case, it might still be inside the polygon (for concave polygons).
          Similarly, you calculate $vec n_{CD}$. If the point $P$ is in the $ABCD$ plane, the two normal vectors are parallel (or anti parallel). You can check this by doing the cross product one again $$vec n_{AB}timesvec n_{CD}$$
          When $P$ is in the plane, the cross product is $0$.



          The other part of the problem is to check if the point $P$ on the plane is between $ABCD$. If it is, it means that the projection of $P$ on the $xy$ plane is between the projection of $ABCD$ in the $xy$ plane. To solve this problem, there are many possible solution. Here is a possible choice. You can also look at the links on this wikipedia page






          share|cite|improve this answer





















            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: "69"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3026160%2fhow-to-check-if-a-point-lies-withing-a-4-point-polygon-in-3d-space%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The first thing you want to check is that your point, let's call it $P$, lies in the plane of polygon $ABCD$. You can use vectors and cross products for this step. You know that any three points form a plane. You can describe this plane by the normal to the plane. $$vec n_{PAB}propto (vec P-vec A)times(vec P-vec B)$$
            If the cross product is zero, it means that $P$ lies on the $AB$ line, and all you need to check if it is between $A$ and $B$. For that, use scalar product: $$ (vec P-vec A)cdot(vec P-vec B)$$
            If the scalar product is $0$, $P=A$ or $P=B$. If the scalar product is negative, the points is between the two, otherwise is outside. In this last case, it might still be inside the polygon (for concave polygons).
            Similarly, you calculate $vec n_{CD}$. If the point $P$ is in the $ABCD$ plane, the two normal vectors are parallel (or anti parallel). You can check this by doing the cross product one again $$vec n_{AB}timesvec n_{CD}$$
            When $P$ is in the plane, the cross product is $0$.



            The other part of the problem is to check if the point $P$ on the plane is between $ABCD$. If it is, it means that the projection of $P$ on the $xy$ plane is between the projection of $ABCD$ in the $xy$ plane. To solve this problem, there are many possible solution. Here is a possible choice. You can also look at the links on this wikipedia page






            share|cite|improve this answer


























              0














              The first thing you want to check is that your point, let's call it $P$, lies in the plane of polygon $ABCD$. You can use vectors and cross products for this step. You know that any three points form a plane. You can describe this plane by the normal to the plane. $$vec n_{PAB}propto (vec P-vec A)times(vec P-vec B)$$
              If the cross product is zero, it means that $P$ lies on the $AB$ line, and all you need to check if it is between $A$ and $B$. For that, use scalar product: $$ (vec P-vec A)cdot(vec P-vec B)$$
              If the scalar product is $0$, $P=A$ or $P=B$. If the scalar product is negative, the points is between the two, otherwise is outside. In this last case, it might still be inside the polygon (for concave polygons).
              Similarly, you calculate $vec n_{CD}$. If the point $P$ is in the $ABCD$ plane, the two normal vectors are parallel (or anti parallel). You can check this by doing the cross product one again $$vec n_{AB}timesvec n_{CD}$$
              When $P$ is in the plane, the cross product is $0$.



              The other part of the problem is to check if the point $P$ on the plane is between $ABCD$. If it is, it means that the projection of $P$ on the $xy$ plane is between the projection of $ABCD$ in the $xy$ plane. To solve this problem, there are many possible solution. Here is a possible choice. You can also look at the links on this wikipedia page






              share|cite|improve this answer
























                0












                0








                0






                The first thing you want to check is that your point, let's call it $P$, lies in the plane of polygon $ABCD$. You can use vectors and cross products for this step. You know that any three points form a plane. You can describe this plane by the normal to the plane. $$vec n_{PAB}propto (vec P-vec A)times(vec P-vec B)$$
                If the cross product is zero, it means that $P$ lies on the $AB$ line, and all you need to check if it is between $A$ and $B$. For that, use scalar product: $$ (vec P-vec A)cdot(vec P-vec B)$$
                If the scalar product is $0$, $P=A$ or $P=B$. If the scalar product is negative, the points is between the two, otherwise is outside. In this last case, it might still be inside the polygon (for concave polygons).
                Similarly, you calculate $vec n_{CD}$. If the point $P$ is in the $ABCD$ plane, the two normal vectors are parallel (or anti parallel). You can check this by doing the cross product one again $$vec n_{AB}timesvec n_{CD}$$
                When $P$ is in the plane, the cross product is $0$.



                The other part of the problem is to check if the point $P$ on the plane is between $ABCD$. If it is, it means that the projection of $P$ on the $xy$ plane is between the projection of $ABCD$ in the $xy$ plane. To solve this problem, there are many possible solution. Here is a possible choice. You can also look at the links on this wikipedia page






                share|cite|improve this answer












                The first thing you want to check is that your point, let's call it $P$, lies in the plane of polygon $ABCD$. You can use vectors and cross products for this step. You know that any three points form a plane. You can describe this plane by the normal to the plane. $$vec n_{PAB}propto (vec P-vec A)times(vec P-vec B)$$
                If the cross product is zero, it means that $P$ lies on the $AB$ line, and all you need to check if it is between $A$ and $B$. For that, use scalar product: $$ (vec P-vec A)cdot(vec P-vec B)$$
                If the scalar product is $0$, $P=A$ or $P=B$. If the scalar product is negative, the points is between the two, otherwise is outside. In this last case, it might still be inside the polygon (for concave polygons).
                Similarly, you calculate $vec n_{CD}$. If the point $P$ is in the $ABCD$ plane, the two normal vectors are parallel (or anti parallel). You can check this by doing the cross product one again $$vec n_{AB}timesvec n_{CD}$$
                When $P$ is in the plane, the cross product is $0$.



                The other part of the problem is to check if the point $P$ on the plane is between $ABCD$. If it is, it means that the projection of $P$ on the $xy$ plane is between the projection of $ABCD$ in the $xy$ plane. To solve this problem, there are many possible solution. Here is a possible choice. You can also look at the links on this wikipedia page







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Dec 4 '18 at 21:52









                AndreiAndrei

                11.4k21026




                11.4k21026






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics 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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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.


                    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%2fmath.stackexchange.com%2fquestions%2f3026160%2fhow-to-check-if-a-point-lies-withing-a-4-point-polygon-in-3d-space%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

                    Berounka

                    Sphinx de Gizeh

                    Different font size/position of beamer's navigation symbols template's content depending on regular/plain...