Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to rotate the region between y=cos(x) and y=x^2 - 0.25*pi^2 about the line x=pi. How to do this? So far I have only managed to rotate around the x-axis:

\documentclass[letterpaper]{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[view={60}{30}]
    \addplot3[surf,shader=flat,
      samples=20,
      color=red, opacity=0.15,
      domain=-0.5*pi:0.5*pi, y domain=0:2*pi,
      z buffer=sort]
     ({x * cos(deg(y))}, {x * sin(deg(y)) }, {cos(deg(x))});
   \addplot3[surf,shader=flat,
     samples=20,
     color=red, opacity=0.15,
     domain=-0.5*pi:0.5*pi, y domain=0:2*pi,
     z buffer=sort]
    ({x * cos(deg(y))}, {x * sin(deg(y)) }, {x*x - 0.25*pi^2});
   \end{axis}
\end{tikzpicture}

\end{document}

Which produces:
solid of revolution

However, the solid should be more of a donut shape.

Edit: To clarify, I wish to produce a graphic of the solid that this rotation will generate: question

share|improve this question
    
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. –  Adam Liter Jul 27 at 23:04
    
Revolution about an arbitrary axis sounds more like you need to look up how a rotation matrix looks like in 3D. –  Turion Jul 30 at 15:04
    
Also, how is x=pi a line? It's a plane, I'd say. –  Turion Jul 30 at 15:06
    
@Turion That rotation matrix stuff looks complicated. Even if I understood the mathematical basis behind it (which I probably could if I spent some time on it), I still wouldn't know how to implement it in tikz\LaTex. Also, from my problem set, "revolved around the line x = pi". The original question was not presented in an x,y,z coordinate system, I only introduced x,y,z in an attempt to plot the solid of revolution. –  thejmazz Jul 30 at 15:44
    
@thejmazz, ok, if you're not interested in rotations about arbitrary axes, we should be able to do it without. I still don't understand what is meant by "the line x = pi". To specify a line, you either need two constraints on coordinates (like x=pi, y=0) or a base vector and a direction vector. –  Turion Jul 30 at 15:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.