# how to distinguish clockwise from counterclockwise rotation

I need to distiguish the true rotation of a vector (time dependent, solution of a system of two coupled differential equation) respect a fixed vector. As showed in the follow,neither VectorAngle nor ArcCos work, because they yeld only positive results (i.e. as a counterclockwise rotation). I'm sure (from physical reasoning that the correct result is the opposite).

sol1 = FullSimplify[
DSolve[{y'[t] == -3 y[t] - z[t], z'[t] == -0.6 z[t] + y[t],
y[0] == 0, z[0] == 1}, {y[t], z[t]}, t]];

{{Gy[t_], Gz[t_]}} = {-z[t], y[t]} /. sol1;

sol2 = FullSimplify[
DSolve[{vy'[t] == -3 vy[t] - vz[t],
vz'[t] == -0.6 vz[t] +  vy[t], vy[T] == Gy[T],
vz[T] == Gz[T]}, {vy[t], vz[t]}, t]];

{{VY[t_], VZ[t_]}} = Simplify[{vy[t], vz[t]} /. sol2];

ang[T_]= VectorAngle[{Gy[0], Gz[0]}, {VY[0], VZ[0]}];

Plot[ang[T], {T, 0, 8}, PlotRange -> Full]

You can see, if you compile the code, that the plot result is:

I can obtain the correct result if I put an overall minus sign in VectorAngle, but obviously this is an incorrect procedure. I show her the output just for say you what is the "correct" output (as I said previously, I motivate it by physical reasoning)

• To "orient a space" you need an external product like op. Try Cross[] Mar 18 '14 at 16:44
• ArcTan[x,y] may be also used.
– Kuba
Mar 18 '14 at 16:51
• @Kuba: I think there is no difference between ArcTan, ArcCos and VectorAngle (I'have just try with ArcCos and I've obtain the same result)... Mar 18 '14 at 17:18
• @belisarius : Then I have to embed the vectors in a 3D space...do you agree? But how I do this? I tried with:Cross[{Normalize[{Gy[0], Gz[0], 0}]}, {Normalize[{VY[0], VZ[0], 0}]}]...to extract a Sin...but I obtain an error Mar 18 '14 at 17:22
• See this answer Using the epsilon tensor in Mathematica demonstrating how the Curl operator can be used for your purpuse. Mar 18 '14 at 18:49

I'd suggest using a difference of ArcTan as Kuba implies. ArcSin @Last@Cross[{Normalize[{Gy[0], Gz[0], 0}]}, {Normalize[{VY[0], VZ[0], 0}]}] has a similar problem with range that VectorAngle has.

ang[T_] = ArcTan[VY[0], VZ[0]] - ArcTan[Gy[0], Gz[0]];

Plot[ang[T], {T, 0, 8}, PlotRange -> Full]

It also works this way:

Clear[ang];
ang[T0_?NumericQ] :=
ArcTan @@ First @ RotationMatrix[{{VY[0], VZ[0]}, {Gy[0], Gz[0]}} /. T -> T0];
• Thank you very much! I was writting that I had the same problem with Cross, as you say, when you posted correct solution! Mar 18 '14 at 18:01