TransWikia.com

Rotating surface in z axis

TeX - LaTeX Asked on June 4, 2021

I have the following code to plot a surface:

documentclass[tikz,border=5mm]{standalone}
usepackage{tikz,pgfplots}

begin{document}

begin{tikzpicture}
begin{axis}[xmin=-4,,zmax=5,zmin=-2,xmax=4,ymin=-4,ymax=4,axis lines=center,view={150}{20}]
node [right] at (axis cs:6.2,0,0) {eixo-$x$};
node [above] at (axis cs:0,6.2,0) {eixo-$y$};
node [above] at (axis cs:0,0,5.1) {eixo-$z$};
    addplot3[surf,faceted color=teal,color=teal,opacity=0.5,fill opacity=0.2,opacity=0.5,domain=0:2,y domain=0:360,samples=40]
    ({x*cos(y)/sqrt(0.4)}, {1+x*sin(y)}, {x^2-1});
end{axis}
end{tikzpicture}

end{document}

I would like to rotate this surface 30 degrees considering the projection on xy plane. How can I do this?

One Answer

This rotates the plot about the z-axis. The rotation angle is alphar. Depending on your conventions you may need -30.

documentclass[tikz,border=5mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.17}
begin{document}

begin{tikzpicture}
begin{axis}[xmin=-4,,zmax=5,zmin=-2,xmax=4,ymin=-4,ymax=4,
axis lines=center,view={150}{20},declare function={alphar=30;
    fx(x,y)=x*cos(y)/sqrt(0.4);fy(x,y)=1+x*sin(y);}]
node [right] at (axis cs:6.2,0,0) {eixo-$x$};
node [above] at (axis cs:0,6.2,0) {eixo-$y$};
node [above] at (axis cs:0,0,5.1) {eixo-$z$};
    addplot3[surf,faceted color=teal,color=teal,opacity=0.5,fill opacity=0.2,opacity=0.5,domain=0:2,y domain=0:360,samples=40]
    ({cos(alphar)*fx(x,y)+sin(alphar)*fy(x,y)}, 
    {cos(alphar)*fy(x,y)-sin(alphar)*fx(x,y)}, {x^2-1});
end{axis}
end{tikzpicture}
end{document}

enter image description here

Answered by user230294 on June 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP