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: plot-output, but it'is incorrect

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)correct plot-output

  • 1
    $\begingroup$ To "orient a space" you need an external product like op. Try Cross[] $\endgroup$ Mar 18 '14 at 16:44
  • $\begingroup$ ArcTan[x,y] may be also used. $\endgroup$
    – Kuba
    Mar 18 '14 at 16:51
  • $\begingroup$ @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)... $\endgroup$
    – Mike84
    Mar 18 '14 at 17:18
  • $\begingroup$ @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 $\endgroup$
    – Mike84
    Mar 18 '14 at 17:22
  • $\begingroup$ See this answer Using the epsilon tensor in Mathematica demonstrating how the Curl operator can be used for your purpuse. $\endgroup$
    – Artes
    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]

Mathematica graphics

It also works this way:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.