Riccardo GUIDA wrote:
> 
> I'm sorry I do not yet have a developer framework setup (virtual machine, git 
> ...) so you must content yourselves with an untested METAPATCH. ric
> 
> PROBLEM:
> Crazy behavior of viewpoint function invoked by command line.
> 
> BUG:
> Evident confusion among radians and degrees in the implementation of 
> viewpoint.
> 
> CONVENTIONS:
> A viewpoint is a data record inside ThreeDimensionalViewport and has type
> 
> V ==> Record( theta : SF, phi : SF, scale : SF, scaleX : SF, scaleY : SF, 
> scaleZ : SF, deltaX : SF, deltaY : SF )
> https://github.com/fricas/fricas/blob/master/src/algebra/view3D.spad#L39
> 
> where, believing to the ++ descriptions, theta is the longitude and phi the 
> latitude (Mmmm... physicists use the opposite convention).
> 
> Conversion factors degrees to radians are defined by
> degrees := pi()$F / 180.0
> degreesSF := pi()$SF / 180
> https://github.com/fricas/fricas/blob/master/src/algebra/view3D.spad#L401
> 
>  From the use of the most primitive function rotate one understands that 
> theta and phi in V are in radians and Float
> https://github.com/fricas/fricas/blob/master/src/algebra/view3D.spad#L801
> 
> I do not really understand the difference among the detailed actions
> of rotate (line 801) and viewpint (Line 703) because depend on the server.
> I *guess* that for given theta, phi they act in the same way, while viewpoint 
> (Line 703)  updates all the fields.
> 
> It would be nice to double check these conventions but I'm unable to dive in 
> ViewportServer$Lisp
> 
> METAPATCHES:
> 
> 1) https://github.com/fricas/fricas/blob/master/src/algebra/view3D.spad#L728
> 
> radian/degree mismatch: delete the two occurrences of * degreesSF below:
> 
>      viewpoint (viewport : %, Theta : F, Phi : F) : Void ==
>        viewport.viewpoint.theta := convert(Theta)@SF * degreesSF
>        viewport.viewpoint.phi := convert(Phi)@SF * degreesSF
> 
> 2)
> https://github.com/fricas/fricas/blob/master/src/algebra/view3D.spad#L742
> 
> 2.1: Replace 180.0 by %pi   and 90.0 by %pi/2 below
> 2.2: The two occurrences of * degrees in rotate must be deleted.
>       (Modification 2.2 is superseeded by 4.2 below)
> 
>      viewpoint (viewport : %, X : F, Y : F, Z : F) : Void ==
>        Theta : F
>        Phi : F
>        if (X = 0$F) and (Y = 0$F) then
>          Theta := 0$F
>          if (Z>=0$F) then
>            Phi := 0$F
>          else
>            Phi := 180.0
>        else
>          Theta := asin(Y/(R := sqrt(X*X+Y*Y)))
>          if (Z = 0$F) then
>            Phi := 90.0
>          else
>            Phi := atan(Z/R)
> rotate(viewport, Theta * degrees, Phi * degrees)

The changes above are clear.

> 2.3 The corresponding ++ description is wrong
> https://github.com/fricas/fricas/blob/master/src/algebra/view3D.spad#L242
> 
> The corresponding ++ description is wrong:
> 
>      viewpoint             : (%, F, F, F)                                -> 
> Void
>        ++ viewpoint(v, rotx, roty, rotz) sets the rotation about the x-axis
>        ++ to be \spad{rotx} radians, sets the rotation about the y-axis
>        ++ to be \spad{roty} radians, and sets the rotation about the z-axis
>        ++ to be \spad{rotz} radians, for the viewport v, which is of the
>        ++ domain \spadtype{ThreeDimensionalViewport} and displays v with
>        ++ the new view position.
> 
> If I understand correctly the new description should be
> 
>      viewpoint             : (%, F, F, F)                                -> 
> Void
>        ++ viewpoint(v, x, y, z) sets the viewpoint to cartesian coordinates 
> (x,y,z)
>        ++ for the viewport v, which is of the
>        ++ domain \spadtype{ThreeDimensionalViewport} and displays v with
>        ++ the new view position.

Sorry, original description is clearly wrong, but the proposed
replacement is not clear for me.  To say the truth my understanding
is that the routine converts coordinates to angle(s) on the sphere,
but ATM I do not see why anybody would want such a routine.
Probably first we need to know what those angles really mean.
Saying longitude and latitude avoids real question: what is their
role in display.

> 
> 3)
> You may safely delete the lines 425 to 431 because arcsinTemp and arctanTemp 
> are unused.
> (Can one call them from other files?)
> 
> https://github.com/fricas/fricas/blob/master/src/algebra/view3D.spad#L425

Clear, they are unused.

> 4) SUGGESTED FEATURE: let ALL viewpoint functions to force replotting the 
> viewport.

Sorry, not replotting is the feature.  It is impossible to "undo"
spurious replot.  On fast displays spurious replots merely waste
time but on slow ones can create ugly artifacts.  So quality
plotting routines must give user control of replotting.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to