spins: Spin the current rgl window continuously

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/spins.R

Description

Spins the current rgl window with constant increment(s) in theta and/or phi. Use <ESC> in the R window to stop.

Usage

1
spins(inc.theta = 1/4, inc.phi = 0, theta = NULL, phi = NULL)

Arguments

inc.theta

Increment for rotation about the vertical, y, axis.

inc.phi

Increment for rotation around the x axis.

theta

Initial value for theta. By default, the current orientation is used.

phi

Initial value for phi. By default, the current orientation is used.

Details

TBW

Value

None

Author(s)

Georges Monette

See Also

spin, spin3d

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function( inc.theta = 1/4, inc.phi = 0, theta = NULL, phi = NULL) {
 help = "
    Spins the current rgl window with a constant increment in theta and phi.
    Use ESC in R window to stop.
    BUG: - Respects some mouse motions but behaves unpredictably.
         - Should have a better way to stop
 "
      um <- par3d('userMatrix')
      Acos = function(x) 360*acos(x)/(2*pi)
      Asin = function(x) 360*asin(x)/(2*pi)
      Atan2 = function( s, c) atan2( s, c)*(180/pi)
      theta.phi = function( ) {

          par3d()
          um = par3d('userMatrix')
          list(theta = Atan2(-um[1,3], um[1,1]), phi = Atan2 (um[3,2],um[2,2]))
      }

      tp = theta.phi()
      if(is.null(theta)) theta = tp$theta
      if(is.null(phi)) phi = tp$phi
      while(TRUE) {
           theta = (theta + inc.theta) %% 360
           phi = phi + inc.phi
           spin( theta = theta , phi = phi)
           tp = theta.phi()
           # print( tp )
           theta = tp$theta
           phi = tp$phi
      }
      invisible(NULL)
  }

p3d documentation built on May 2, 2019, 5:25 p.m.