Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rglToLattice

Convert RGL userMatrix to lattice or base angles


Description

These functions take a user orientation matrix from an RGL scene and approximate the parameters to either lattice or base graphics functions.

Usage

rglToLattice(rotm = par3d("userMatrix"))
rglToBase(rotm = par3d("userMatrix"))

Arguments

rotm

A matrix in homogeneous coordinates to convert.

Details

The lattice package can use Euler angles in the ZYX scheme to describe the rotation of a scene in its wireframe or cloud functions. The rglToLattice function computes these angles based on rotm, which defaults to the current user matrix. This allows RGL to be used to interactively find a decent viewpoint and then reproduce it in lattice.

The base graphics persp function does not use full Euler angles; it uses a viewpoint angle, and assume the z axis remains vertical. The rglToBase function computes the viewpoint angle accurately if the RGL scene is displayed with a vertical z axis, and does an approximation otherwise.

Value

rglToLattice returns a list suitable to be used as the screen argument to wireframe.

rglToBase returns a list containing theta and phi components which can be used as corresponding arguments in persp.

Author(s)

Duncan Murdoch

Examples

persp3d(volcano, col = "green")
if ((hasorientlib <- requireNamespace("orientlib", quietly = TRUE)) && 
    requireNamespace("lattice", quietly = TRUE)) 
    lattice::wireframe(volcano, screen = rglToLattice())
if (hasorientlib) {
  angles <- rglToBase()
  persp(volcano, col = "green", border = NA, shade = 0.5,
        theta = angles$theta, phi = angles$phi)
}

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.