PlanarAngle Issues 2

20.07.2021, WernerGg
Meanwhile I found out that the symbolic result of PlanarAngle is wrong. The correct symbolic result of PlanarAngle would have to be a Piecewise expression that depends on the relative positions of the points p, q1, q2.
​
See the attached Notebook “210717b PlanarAngle Issues 2.nb”.
​
​I am using Version 12.3.1 on current Windows 10.

PlanarAngle symbolic result is wrong.

◼
  • Meanwhile I found out that the symbolic result of PlanarAngle is wrong. As an example you can see the following code. We rotate the first unit vector (q1) by α2 = 3π/4, 5π/4 ,7π/4 respectively (and their negatives) around the origin (p) into the new position (q2). Then we calculate the rotation angles from these vectors using PlanarAngle.
    ​
    While the direct calculation of PlanarAngle from the concrete vectors always gives the correct result, the result is wrong if we use the symbolic expression provided by PlanarAngle. Namely in our example:
  • In[]:=
    PlanarAngle[{0,0}->{{1,0},{Cos[α2sym],Sin[α2sym]}},"Counterclockwise"]
    Out[]=
    ArcCos[Cos[α2sym]]
    Within the full rotation range -2π to +2π this is true only for
    0 ≤ ϕ ≤ π and -2π ≤ ϕ ≤ -π.
    ​
    ​The correct symbolic result of PlanarAngle would have to be a Piecewise expression that depends on the relative positions of the points p, q1, q2.
    In[]:=
    Remove["Global`*"];ClearSystemCache[];​​Block[{p={0,0},q1={1,0},draw,α2sym,ϕExpr,q2,ϕ,ϕE},​​draw[p_,q1_,α2_,ϕ_]=Module[{myq2},​​myq2={Cos[α2],Sin[α2]};​​Graphics[{Thick,​​Blue,Line[{p,q1}],Red,Line[{p,myq2}],Circle[p,0.5,{0,ϕ}]},Axes->True,PlotLabel->Style[Column[{Row[{"α2 = ",α2," (",180α2/π,"°)"}],Row[{"ϕ = ",ϕ," (",180ϕ/π,"°)"}]},Center],Blue,Bold],ImageSize->Small]​​];​​(*ThegenaralExpressionforthisPlanarAngle*)​​ϕExpr=PlanarAngle[p->{q1,{Cos[α2sym],Sin[α2sym]}},"Counterclockwise"];​​Print[Style[Row[{"ϕExpr = ",ϕExpr}],Red,Bold]];​​Do[​​q2={Cos[α2],Sin[α2]};​​(*ϕ=Straightcalculationofϕ*)​​ϕ=PlanarAngle[p->{q1,q2},"Counterclockwise"];​​(*ϕE=CalculationofϕfromϕExprbyReplace*)​​ϕE=ϕExpr/.{α2sym->α2};​​Print[Grid[{{Column[{"ϕ straight from:","PlanarAngle[p->{q1,q2}]"},Center],Column[{"ϕ from ϕExpr:",ϕExpr},Center]},{draw[p,q1,α2,ϕ],draw[p,q1,α2,ϕE]}}]];​​,{α2,{3π/4,5π/4,7π/4,-3π/4,-5π/4,-7π/4}}]​​]
    ϕExpr = ArcCos[Cos[α2sym]]
    ϕ straight from:
    PlanarAngle[p->{q1,q2}]
    ϕ from ϕExpr:
    ArcCos[Cos[α2sym]]
    ϕ straight from:
    PlanarAngle[p->{q1,q2}]
    ϕ from ϕExpr:
    ArcCos[Cos[α2sym]]
    ϕ straight from:
    PlanarAngle[p->{q1,q2}]
    ϕ from ϕExpr:
    ArcCos[Cos[α2sym]]
    ϕ straight from:
    PlanarAngle[p->{q1,q2}]
    ϕ from ϕExpr:
    ArcCos[Cos[α2sym]]
    ϕ straight from:
    PlanarAngle[p->{q1,q2}]
    ϕ from ϕExpr:
    ArcCos[Cos[α2sym]]
    ϕ straight from:
    PlanarAngle[p->{q1,q2}]
    ϕ from ϕExpr:
    ArcCos[Cos[α2sym]]
    In[]:=
    Plot[{Cos[α],ArcCos[Cos[α]]},{α,-2π,2π}]
    Out[]=
    -6
    -4
    -2
    2
    4
    6
    -1
    1
    2
    3

    Version

    In[]:=
    Print["Executed with Version ",$Version," under current Windows 10"]
    Executed with Version 12.3.1 for Microsoft Windows (64-bit) (June 24, 2021) under current Windows 10
    In[]:=
    $LicenseID
    Out[]=
    L3928-9112

    Community

    ◼
  • xy, 20.07.21
  • I am ...
    ◼
  • Werner Geiger, 20.07.21 -> Wolfram Technical Support: support@wolfram.com
  • Meanwhile I found out that the symbolic result of PlanarAngle is wrong. The correct symbolic result of PlanarAngle would have to be a Piecewise expression that depends on the relative positions of the points p, q1, q2.
    ​
    See the attached Notebook “210717b PlanarAngle Issues 2.nb”.
    ​
    ​I am using Version 12.3.1 on current Windows 10.