Coordinate system with tikz-3dplot












2















I am trying to use tikz-3dplot to draw a cube and I was particularly interested by the possibility to define a point using tdplotsetcoord which allows to get x/y/z/xz... coordinates. But when I try to define a point in (4,4,4) of the main coordinate system of tikz-3dplot (so tdplotsetcoord{P}{sqrt(3)*4}{45}{45} I think), I do not get what I am expecting as you can see below. The blue and black nodes should be the same in my figure. Any ideas ?



documentclass[tikz]{standalone}
usepackage{tikz-3dplot}
begin{document}

tdplotsetmaincoords{70}{110}
begin{tikzpicture}[tdplot_main_coords]

% cube
tdplotsetcoord{P}{sqrt(3)*4}{45}{45}
draw[dashed]
(0,0,0) -- (Px)
(0,0,0) -- (Py)
(0,0,0) -- (Pz);
draw[->]
(Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
draw[->]
(Py) -- ++(0,1,0) node[anchor=north west]{$y$};
draw[->]
(Pz) -- ++(0,0,1) node[anchor=south]{$z$};

draw[thick]
(Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
draw[thick]
(Pyz) -- (Py) -- (Pxy);

filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

filldraw[dashed] (0,0,0)-- (4,4,4) circle (2pt);

end{tikzpicture}
end{document}


enter image description here










share|improve this question


















  • 2





    Welcome to TeX-SE! Could you please explain why you expect that(r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4) for theta=phi=45?

    – marmot
    Apr 2 at 13:49


















2















I am trying to use tikz-3dplot to draw a cube and I was particularly interested by the possibility to define a point using tdplotsetcoord which allows to get x/y/z/xz... coordinates. But when I try to define a point in (4,4,4) of the main coordinate system of tikz-3dplot (so tdplotsetcoord{P}{sqrt(3)*4}{45}{45} I think), I do not get what I am expecting as you can see below. The blue and black nodes should be the same in my figure. Any ideas ?



documentclass[tikz]{standalone}
usepackage{tikz-3dplot}
begin{document}

tdplotsetmaincoords{70}{110}
begin{tikzpicture}[tdplot_main_coords]

% cube
tdplotsetcoord{P}{sqrt(3)*4}{45}{45}
draw[dashed]
(0,0,0) -- (Px)
(0,0,0) -- (Py)
(0,0,0) -- (Pz);
draw[->]
(Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
draw[->]
(Py) -- ++(0,1,0) node[anchor=north west]{$y$};
draw[->]
(Pz) -- ++(0,0,1) node[anchor=south]{$z$};

draw[thick]
(Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
draw[thick]
(Pyz) -- (Py) -- (Pxy);

filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

filldraw[dashed] (0,0,0)-- (4,4,4) circle (2pt);

end{tikzpicture}
end{document}


enter image description here










share|improve this question


















  • 2





    Welcome to TeX-SE! Could you please explain why you expect that(r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4) for theta=phi=45?

    – marmot
    Apr 2 at 13:49
















2












2








2








I am trying to use tikz-3dplot to draw a cube and I was particularly interested by the possibility to define a point using tdplotsetcoord which allows to get x/y/z/xz... coordinates. But when I try to define a point in (4,4,4) of the main coordinate system of tikz-3dplot (so tdplotsetcoord{P}{sqrt(3)*4}{45}{45} I think), I do not get what I am expecting as you can see below. The blue and black nodes should be the same in my figure. Any ideas ?



documentclass[tikz]{standalone}
usepackage{tikz-3dplot}
begin{document}

tdplotsetmaincoords{70}{110}
begin{tikzpicture}[tdplot_main_coords]

% cube
tdplotsetcoord{P}{sqrt(3)*4}{45}{45}
draw[dashed]
(0,0,0) -- (Px)
(0,0,0) -- (Py)
(0,0,0) -- (Pz);
draw[->]
(Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
draw[->]
(Py) -- ++(0,1,0) node[anchor=north west]{$y$};
draw[->]
(Pz) -- ++(0,0,1) node[anchor=south]{$z$};

draw[thick]
(Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
draw[thick]
(Pyz) -- (Py) -- (Pxy);

filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

filldraw[dashed] (0,0,0)-- (4,4,4) circle (2pt);

end{tikzpicture}
end{document}


enter image description here










share|improve this question














I am trying to use tikz-3dplot to draw a cube and I was particularly interested by the possibility to define a point using tdplotsetcoord which allows to get x/y/z/xz... coordinates. But when I try to define a point in (4,4,4) of the main coordinate system of tikz-3dplot (so tdplotsetcoord{P}{sqrt(3)*4}{45}{45} I think), I do not get what I am expecting as you can see below. The blue and black nodes should be the same in my figure. Any ideas ?



documentclass[tikz]{standalone}
usepackage{tikz-3dplot}
begin{document}

tdplotsetmaincoords{70}{110}
begin{tikzpicture}[tdplot_main_coords]

% cube
tdplotsetcoord{P}{sqrt(3)*4}{45}{45}
draw[dashed]
(0,0,0) -- (Px)
(0,0,0) -- (Py)
(0,0,0) -- (Pz);
draw[->]
(Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
draw[->]
(Py) -- ++(0,1,0) node[anchor=north west]{$y$};
draw[->]
(Pz) -- ++(0,0,1) node[anchor=south]{$z$};

draw[thick]
(Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
draw[thick]
(Pyz) -- (Py) -- (Pxy);

filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

filldraw[dashed] (0,0,0)-- (4,4,4) circle (2pt);

end{tikzpicture}
end{document}


enter image description here







tikz-3dplot






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 2 at 13:36









Pierre MarchandPierre Marchand

132




132








  • 2





    Welcome to TeX-SE! Could you please explain why you expect that(r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4) for theta=phi=45?

    – marmot
    Apr 2 at 13:49
















  • 2





    Welcome to TeX-SE! Could you please explain why you expect that(r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4) for theta=phi=45?

    – marmot
    Apr 2 at 13:49










2




2





Welcome to TeX-SE! Could you please explain why you expect that(r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4) for theta=phi=45?

– marmot
Apr 2 at 13:49







Welcome to TeX-SE! Could you please explain why you expect that(r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4) for theta=phi=45?

– marmot
Apr 2 at 13:49












1 Answer
1






active

oldest

votes


















2














Welcome to TeX-SE! One way to compute the spherical coordinates of (4,4,4) is to solve



(r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4)


which gives r=4*sqrt(3) and phi=45, as you got, and theta=asin(sqrt(2/3)), which differs from what you have. BTW, you can use also the spherical coordinates of the 3d library, which follow slightly different conventions. The following MWE shows that the outcome is consistent with the above considerations.



documentclass[tikz]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{3d}
begin{document}

tdplotsetmaincoords{70}{110}
begin{tikzpicture}[tdplot_main_coords]
pgfmathsetmacro{mytheta}{asin(sqrt(2/3))}
typeout{mytheta}
% cube
tdplotsetcoord{P}{sqrt(3)*4}{mytheta}{45}
draw[dashed]
(0,0,0) -- (Px)
(0,0,0) -- (Py)
(0,0,0) -- (Pz);
draw[->]
(Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
draw[->]
(Py) -- ++(0,1,0) node[anchor=north west]{$y$};
draw[->]
(Pz) -- ++(0,0,1) node[anchor=south]{$z$};

draw[thick]
(Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
draw[thick]
(Pyz) -- (Py) -- (Pxy);

filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

draw[green!70!black] (4,4,4) circle (3pt);

draw[red] (xyz spherical cs:radius={4*sqrt(3)},
longitude=45,latitude=90-mytheta) circle (4pt);
end{tikzpicture}
end{document}


enter image description here






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    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%2ftex.stackexchange.com%2fquestions%2f482775%2fcoordinate-system-with-tikz-3dplot%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














    Welcome to TeX-SE! One way to compute the spherical coordinates of (4,4,4) is to solve



    (r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4)


    which gives r=4*sqrt(3) and phi=45, as you got, and theta=asin(sqrt(2/3)), which differs from what you have. BTW, you can use also the spherical coordinates of the 3d library, which follow slightly different conventions. The following MWE shows that the outcome is consistent with the above considerations.



    documentclass[tikz]{standalone}
    usepackage{tikz-3dplot}
    usetikzlibrary{3d}
    begin{document}

    tdplotsetmaincoords{70}{110}
    begin{tikzpicture}[tdplot_main_coords]
    pgfmathsetmacro{mytheta}{asin(sqrt(2/3))}
    typeout{mytheta}
    % cube
    tdplotsetcoord{P}{sqrt(3)*4}{mytheta}{45}
    draw[dashed]
    (0,0,0) -- (Px)
    (0,0,0) -- (Py)
    (0,0,0) -- (Pz);
    draw[->]
    (Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
    draw[->]
    (Py) -- ++(0,1,0) node[anchor=north west]{$y$};
    draw[->]
    (Pz) -- ++(0,0,1) node[anchor=south]{$z$};

    draw[thick]
    (Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
    draw[thick]
    (Pyz) -- (Py) -- (Pxy);

    filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

    draw[green!70!black] (4,4,4) circle (3pt);

    draw[red] (xyz spherical cs:radius={4*sqrt(3)},
    longitude=45,latitude=90-mytheta) circle (4pt);
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer




























      2














      Welcome to TeX-SE! One way to compute the spherical coordinates of (4,4,4) is to solve



      (r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4)


      which gives r=4*sqrt(3) and phi=45, as you got, and theta=asin(sqrt(2/3)), which differs from what you have. BTW, you can use also the spherical coordinates of the 3d library, which follow slightly different conventions. The following MWE shows that the outcome is consistent with the above considerations.



      documentclass[tikz]{standalone}
      usepackage{tikz-3dplot}
      usetikzlibrary{3d}
      begin{document}

      tdplotsetmaincoords{70}{110}
      begin{tikzpicture}[tdplot_main_coords]
      pgfmathsetmacro{mytheta}{asin(sqrt(2/3))}
      typeout{mytheta}
      % cube
      tdplotsetcoord{P}{sqrt(3)*4}{mytheta}{45}
      draw[dashed]
      (0,0,0) -- (Px)
      (0,0,0) -- (Py)
      (0,0,0) -- (Pz);
      draw[->]
      (Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
      draw[->]
      (Py) -- ++(0,1,0) node[anchor=north west]{$y$};
      draw[->]
      (Pz) -- ++(0,0,1) node[anchor=south]{$z$};

      draw[thick]
      (Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
      draw[thick]
      (Pyz) -- (Py) -- (Pxy);

      filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

      draw[green!70!black] (4,4,4) circle (3pt);

      draw[red] (xyz spherical cs:radius={4*sqrt(3)},
      longitude=45,latitude=90-mytheta) circle (4pt);
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer


























        2












        2








        2







        Welcome to TeX-SE! One way to compute the spherical coordinates of (4,4,4) is to solve



        (r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4)


        which gives r=4*sqrt(3) and phi=45, as you got, and theta=asin(sqrt(2/3)), which differs from what you have. BTW, you can use also the spherical coordinates of the 3d library, which follow slightly different conventions. The following MWE shows that the outcome is consistent with the above considerations.



        documentclass[tikz]{standalone}
        usepackage{tikz-3dplot}
        usetikzlibrary{3d}
        begin{document}

        tdplotsetmaincoords{70}{110}
        begin{tikzpicture}[tdplot_main_coords]
        pgfmathsetmacro{mytheta}{asin(sqrt(2/3))}
        typeout{mytheta}
        % cube
        tdplotsetcoord{P}{sqrt(3)*4}{mytheta}{45}
        draw[dashed]
        (0,0,0) -- (Px)
        (0,0,0) -- (Py)
        (0,0,0) -- (Pz);
        draw[->]
        (Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
        draw[->]
        (Py) -- ++(0,1,0) node[anchor=north west]{$y$};
        draw[->]
        (Pz) -- ++(0,0,1) node[anchor=south]{$z$};

        draw[thick]
        (Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
        draw[thick]
        (Pyz) -- (Py) -- (Pxy);

        filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

        draw[green!70!black] (4,4,4) circle (3pt);

        draw[red] (xyz spherical cs:radius={4*sqrt(3)},
        longitude=45,latitude=90-mytheta) circle (4pt);
        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer













        Welcome to TeX-SE! One way to compute the spherical coordinates of (4,4,4) is to solve



        (r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),r*sin(theta))=(4,4,4)


        which gives r=4*sqrt(3) and phi=45, as you got, and theta=asin(sqrt(2/3)), which differs from what you have. BTW, you can use also the spherical coordinates of the 3d library, which follow slightly different conventions. The following MWE shows that the outcome is consistent with the above considerations.



        documentclass[tikz]{standalone}
        usepackage{tikz-3dplot}
        usetikzlibrary{3d}
        begin{document}

        tdplotsetmaincoords{70}{110}
        begin{tikzpicture}[tdplot_main_coords]
        pgfmathsetmacro{mytheta}{asin(sqrt(2/3))}
        typeout{mytheta}
        % cube
        tdplotsetcoord{P}{sqrt(3)*4}{mytheta}{45}
        draw[dashed]
        (0,0,0) -- (Px)
        (0,0,0) -- (Py)
        (0,0,0) -- (Pz);
        draw[->]
        (Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
        draw[->]
        (Py) -- ++(0,1,0) node[anchor=north west]{$y$};
        draw[->]
        (Pz) -- ++(0,0,1) node[anchor=south]{$z$};

        draw[thick]
        (Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P);
        draw[thick]
        (Pyz) -- (Py) -- (Pxy);

        filldraw[dashed,blue] (0,0,0)-- (P) circle (2pt);

        draw[green!70!black] (4,4,4) circle (3pt);

        draw[red] (xyz spherical cs:radius={4*sqrt(3)},
        longitude=45,latitude=90-mytheta) circle (4pt);
        end{tikzpicture}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 2 at 14:03









        marmotmarmot

        117k5150283




        117k5150283






























            draft saved

            draft discarded




















































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


            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%2ftex.stackexchange.com%2fquestions%2f482775%2fcoordinate-system-with-tikz-3dplot%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

            How to send String Array data to Server using php in android

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Is anime1.com a legal site for watching anime?