How to define the Cartesian plane in MATLAB












0












$begingroup$


I want to define a small plane in which 'x' changes from (0.5 to 49.5), 'y' changes from (0 to 4.8) and 'z' changes from lets say (2.5 to 4.4). Its like a small piece of a pitched roof placed at an angle of about 22 degrees. I want to get the Cartesian points (x,y,z) of each point in this plane to use them later in some formula. Please help!










share|cite|improve this question









$endgroup$












  • $begingroup$
    If you find this answer helpful, would you mind clicking on the green check (accept) to "conclude" this post? Otherwise it stays in the wrong queue and clog up the system. Thank you.
    $endgroup$
    – Lee David Chung Lin
    Feb 12 at 3:57
















0












$begingroup$


I want to define a small plane in which 'x' changes from (0.5 to 49.5), 'y' changes from (0 to 4.8) and 'z' changes from lets say (2.5 to 4.4). Its like a small piece of a pitched roof placed at an angle of about 22 degrees. I want to get the Cartesian points (x,y,z) of each point in this plane to use them later in some formula. Please help!










share|cite|improve this question









$endgroup$












  • $begingroup$
    If you find this answer helpful, would you mind clicking on the green check (accept) to "conclude" this post? Otherwise it stays in the wrong queue and clog up the system. Thank you.
    $endgroup$
    – Lee David Chung Lin
    Feb 12 at 3:57














0












0








0





$begingroup$


I want to define a small plane in which 'x' changes from (0.5 to 49.5), 'y' changes from (0 to 4.8) and 'z' changes from lets say (2.5 to 4.4). Its like a small piece of a pitched roof placed at an angle of about 22 degrees. I want to get the Cartesian points (x,y,z) of each point in this plane to use them later in some formula. Please help!










share|cite|improve this question









$endgroup$




I want to define a small plane in which 'x' changes from (0.5 to 49.5), 'y' changes from (0 to 4.8) and 'z' changes from lets say (2.5 to 4.4). Its like a small piece of a pitched roof placed at an angle of about 22 degrees. I want to get the Cartesian points (x,y,z) of each point in this plane to use them later in some formula. Please help!







graphing-functions matlab plane-geometry






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Feb 3 at 7:00









user427820user427820

54




54












  • $begingroup$
    If you find this answer helpful, would you mind clicking on the green check (accept) to "conclude" this post? Otherwise it stays in the wrong queue and clog up the system. Thank you.
    $endgroup$
    – Lee David Chung Lin
    Feb 12 at 3:57


















  • $begingroup$
    If you find this answer helpful, would you mind clicking on the green check (accept) to "conclude" this post? Otherwise it stays in the wrong queue and clog up the system. Thank you.
    $endgroup$
    – Lee David Chung Lin
    Feb 12 at 3:57
















$begingroup$
If you find this answer helpful, would you mind clicking on the green check (accept) to "conclude" this post? Otherwise it stays in the wrong queue and clog up the system. Thank you.
$endgroup$
– Lee David Chung Lin
Feb 12 at 3:57




$begingroup$
If you find this answer helpful, would you mind clicking on the green check (accept) to "conclude" this post? Otherwise it stays in the wrong queue and clog up the system. Thank you.
$endgroup$
– Lee David Chung Lin
Feb 12 at 3:57










1 Answer
1






active

oldest

votes


















2












$begingroup$

How to store the points to represent the plane patch really depends on your upstream and downstream modules.



The mathematical analysis is contained in the comments of the code block, where I deliberately print out some of the intermediate results.



x = [0.5 49.5]; y = [0, 48]; z = [2.5 4.4];
Vx = [x(2) - x(1) 0 z(2) - z(1)]; % vector along x, on the plane
Vy = [0 y(2) - y(1) z(2) - z(1)]; % vector along y, on the plane
Vn = cross(Vx, Vy); Vn = Vn / norm(Vn) % unit vector normal to the plane patch

% Plane equation is ax + by + cz = d, where [a b c] = Vn
d = Vn * [x(1) y(1) z(1)]' % Solve for d. Inner product

nX = 23; nY = 37; % user input number of grid points
xBase = linspace( x(1), x(2), nX );
yBase = linspace( y(1), y(2), nY );
[xGrid yGrid] = meshgrid( xBase, yBase );
zGrid = d - (Vn(1) * xGrid - Vn(2) * yGrid ) / Vn(3); % Given any [x y] we have z = (d - ax - by)/c

%{
The requested 3-dim data is established above. Whether you wan to plot it or do
some computation is a different matter.
Note the convention of the origin being on the "top left" so that yGrid
might need flipping for some of the plot functions.
%}
mesh( xGrid, flipud(yGrid), zGrid)
xlabel('X'); ylabel('Y'); zlabel('Z');
axis vis3d % fix aspect ratio when rotating





share|cite|improve this answer









$endgroup$














    Your Answer








    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%2f3098284%2fhow-to-define-the-cartesian-plane-in-matlab%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









    2












    $begingroup$

    How to store the points to represent the plane patch really depends on your upstream and downstream modules.



    The mathematical analysis is contained in the comments of the code block, where I deliberately print out some of the intermediate results.



    x = [0.5 49.5]; y = [0, 48]; z = [2.5 4.4];
    Vx = [x(2) - x(1) 0 z(2) - z(1)]; % vector along x, on the plane
    Vy = [0 y(2) - y(1) z(2) - z(1)]; % vector along y, on the plane
    Vn = cross(Vx, Vy); Vn = Vn / norm(Vn) % unit vector normal to the plane patch

    % Plane equation is ax + by + cz = d, where [a b c] = Vn
    d = Vn * [x(1) y(1) z(1)]' % Solve for d. Inner product

    nX = 23; nY = 37; % user input number of grid points
    xBase = linspace( x(1), x(2), nX );
    yBase = linspace( y(1), y(2), nY );
    [xGrid yGrid] = meshgrid( xBase, yBase );
    zGrid = d - (Vn(1) * xGrid - Vn(2) * yGrid ) / Vn(3); % Given any [x y] we have z = (d - ax - by)/c

    %{
    The requested 3-dim data is established above. Whether you wan to plot it or do
    some computation is a different matter.
    Note the convention of the origin being on the "top left" so that yGrid
    might need flipping for some of the plot functions.
    %}
    mesh( xGrid, flipud(yGrid), zGrid)
    xlabel('X'); ylabel('Y'); zlabel('Z');
    axis vis3d % fix aspect ratio when rotating





    share|cite|improve this answer









    $endgroup$


















      2












      $begingroup$

      How to store the points to represent the plane patch really depends on your upstream and downstream modules.



      The mathematical analysis is contained in the comments of the code block, where I deliberately print out some of the intermediate results.



      x = [0.5 49.5]; y = [0, 48]; z = [2.5 4.4];
      Vx = [x(2) - x(1) 0 z(2) - z(1)]; % vector along x, on the plane
      Vy = [0 y(2) - y(1) z(2) - z(1)]; % vector along y, on the plane
      Vn = cross(Vx, Vy); Vn = Vn / norm(Vn) % unit vector normal to the plane patch

      % Plane equation is ax + by + cz = d, where [a b c] = Vn
      d = Vn * [x(1) y(1) z(1)]' % Solve for d. Inner product

      nX = 23; nY = 37; % user input number of grid points
      xBase = linspace( x(1), x(2), nX );
      yBase = linspace( y(1), y(2), nY );
      [xGrid yGrid] = meshgrid( xBase, yBase );
      zGrid = d - (Vn(1) * xGrid - Vn(2) * yGrid ) / Vn(3); % Given any [x y] we have z = (d - ax - by)/c

      %{
      The requested 3-dim data is established above. Whether you wan to plot it or do
      some computation is a different matter.
      Note the convention of the origin being on the "top left" so that yGrid
      might need flipping for some of the plot functions.
      %}
      mesh( xGrid, flipud(yGrid), zGrid)
      xlabel('X'); ylabel('Y'); zlabel('Z');
      axis vis3d % fix aspect ratio when rotating





      share|cite|improve this answer









      $endgroup$
















        2












        2








        2





        $begingroup$

        How to store the points to represent the plane patch really depends on your upstream and downstream modules.



        The mathematical analysis is contained in the comments of the code block, where I deliberately print out some of the intermediate results.



        x = [0.5 49.5]; y = [0, 48]; z = [2.5 4.4];
        Vx = [x(2) - x(1) 0 z(2) - z(1)]; % vector along x, on the plane
        Vy = [0 y(2) - y(1) z(2) - z(1)]; % vector along y, on the plane
        Vn = cross(Vx, Vy); Vn = Vn / norm(Vn) % unit vector normal to the plane patch

        % Plane equation is ax + by + cz = d, where [a b c] = Vn
        d = Vn * [x(1) y(1) z(1)]' % Solve for d. Inner product

        nX = 23; nY = 37; % user input number of grid points
        xBase = linspace( x(1), x(2), nX );
        yBase = linspace( y(1), y(2), nY );
        [xGrid yGrid] = meshgrid( xBase, yBase );
        zGrid = d - (Vn(1) * xGrid - Vn(2) * yGrid ) / Vn(3); % Given any [x y] we have z = (d - ax - by)/c

        %{
        The requested 3-dim data is established above. Whether you wan to plot it or do
        some computation is a different matter.
        Note the convention of the origin being on the "top left" so that yGrid
        might need flipping for some of the plot functions.
        %}
        mesh( xGrid, flipud(yGrid), zGrid)
        xlabel('X'); ylabel('Y'); zlabel('Z');
        axis vis3d % fix aspect ratio when rotating





        share|cite|improve this answer









        $endgroup$



        How to store the points to represent the plane patch really depends on your upstream and downstream modules.



        The mathematical analysis is contained in the comments of the code block, where I deliberately print out some of the intermediate results.



        x = [0.5 49.5]; y = [0, 48]; z = [2.5 4.4];
        Vx = [x(2) - x(1) 0 z(2) - z(1)]; % vector along x, on the plane
        Vy = [0 y(2) - y(1) z(2) - z(1)]; % vector along y, on the plane
        Vn = cross(Vx, Vy); Vn = Vn / norm(Vn) % unit vector normal to the plane patch

        % Plane equation is ax + by + cz = d, where [a b c] = Vn
        d = Vn * [x(1) y(1) z(1)]' % Solve for d. Inner product

        nX = 23; nY = 37; % user input number of grid points
        xBase = linspace( x(1), x(2), nX );
        yBase = linspace( y(1), y(2), nY );
        [xGrid yGrid] = meshgrid( xBase, yBase );
        zGrid = d - (Vn(1) * xGrid - Vn(2) * yGrid ) / Vn(3); % Given any [x y] we have z = (d - ax - by)/c

        %{
        The requested 3-dim data is established above. Whether you wan to plot it or do
        some computation is a different matter.
        Note the convention of the origin being on the "top left" so that yGrid
        might need flipping for some of the plot functions.
        %}
        mesh( xGrid, flipud(yGrid), zGrid)
        xlabel('X'); ylabel('Y'); zlabel('Z');
        axis vis3d % fix aspect ratio when rotating






        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Feb 3 at 14:03









        Lee David Chung LinLee David Chung Lin

        4,50841342




        4,50841342






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3098284%2fhow-to-define-the-cartesian-plane-in-matlab%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

            MongoDB - Not Authorized To Execute Command

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

            How to fix TextFormField cause rebuild widget in Flutter