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)

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.

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

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

4.1) for the viewpoint at line 720, 724: add at the end the line
        viewpoint(viewport,viewport.viewpoint)

4.2) for the viewpoint at line 732 the replotting should be forced, but to be 
homogeneous I would replace

rotate(viewport, Theta, Phi)

by

viewpoint (viewport, Theta, Phi)

4.3) Delete in the ++ strings the statements
++ The new
++ dimensions are not displayed until the function
++ \spadfun{makeViewport3D} is executed again for v.




--
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