Is there a way to rotate the graph of a function?

Assuming I have the graph of a function $f(x)$ is there function $f_1(f(x))$ that will give me a rotated version of the graph of that function?

For example if I plot $\sin(x)$ I will get a sine wave which straddles the $x$-axis, can I apply a function to $\sin(x)$ to yield a wave that straddles the line that would result from $y = 2x$?

-
The "graph of a function" here is actually the graph of points satisfying an equation relating $x$ and $y$, for example $y = \sin x.$ A perfectly correct answer that was posted below (and accepted) tells us how to rotate the graph of any equation relating $x$ and $y,$ even if the equation cannot be written in the form $y = f(x).$ For example, you can rotate the graph of $y^2 = 4 - 2x^2,$ which is an ellipse, by this same method. –  David K Dec 14 '14 at 21:08

Once you rotate, it need not remain a function (i.e. one $x$ value can have multiple $y$ values corresponding to it).

But you can use the following transformation

$$x' = x\cos \theta - y \sin \theta$$ $$y' = x \sin \theta + y \cos \theta$$

to rotate by an angle of $\theta$. Point $(x,y)$ gets rotated to point $(x',y')$. Note: this is a rotation about the origin.

In your case of $y = 2x$, you need to rotate by $\arctan(2)$.

-
In the specific case of sin(x) if you rotate by something in the range (-pi/4,pi/4) you still have a function because the slope of sin(x) is always less than 1 in absolute value. –  Ross Millikan Jan 12 '11 at 17:34
I think this is what I want. I want to animate something so that it undulates as if it were following a sin wave but not always in parallel to the x axis. –  Omar Kooheji Jan 12 '11 at 17:43
@Omar: It looks like the parameterization that Rasmus refers to will suit you nicely. It gives you x and y each as a function of t and avoids the "double x" problem. –  Ross Millikan Jan 12 '11 at 19:25

In general, the answer is no since the rotated version of the graph might not be the graph of a function. For instance it could happen that your rotated version of the graph contains two different points with the same $x$-value -- this cannot happen for the graph of a function.

A way out could be to parametrise your graph. So instead of a map $x\mapsto y(x)$ you look at the map $t\mapsto (t,y(t))$. After rotating the trajectory of this thing (not the graph!) it will still be the trajectory of a map $$t\mapsto (x(t),y(t)).$$

-

You can do the rotation as Moron says, or you can write $y=2x+\sin(x)$. This will remain a function, but doesn't have the same shape as a sine wave. It depends upon what you want.

-
I've tried this and it yields okay results for what I want to do. I might use this for something else. I'd been trying to multiply when I should have been adding... –  Omar Kooheji Jan 12 '11 at 17:45