[R] Accessing the C++ source associated with the rgl function shade3d

Rasmus Liland jr@| @end|ng |rom po@teo@no
Thu Jul 30 13:15:32 CEST 2020


On 2020-07-30 05:23 -0400, Duncan Murdoch wrote:
> On 29/07/2020 7:27 p.m., Rasmus Liland wrote:
> > On 2020-07-29 18:04 -0400, Duncan Murdoch wrote:
> > > The arrow3d function is also a pure R
> > > function, but not a generic.  You can
> > > see the source by typing "arrow3d".
> > 
> > ... but if I type rgl::shade3d, I get
> > 
> > 	> rgl::shade3d
> > 	function (x, ...)
> > 	UseMethod("shade3d")
> > 	<bytecode: 0x562692966fb8>
> > 	<environment: namespace:rgl>
> 
> That includes the full source code to 
> shade3d.  Like most generic functions, 
> it's a one-liner.
> 
> In the part of my post that you 
> deleted, I told the OP where to look 
> next.

This part:

> > > type "rgl:::shade3d.mesh3d" and you 
> > > can see the full source.

Three colons.  I didn't see it at first; 
Hmm ... I might have dyslexia or 
something ... 

So, Byron, this is the code that R 
reinterprets from the source,

	Rscript -e 'rgl:::arrow3d' | less
	Rscript -e 'rgl:::shade3d.mesh3d' | less

so you cannot necessarily grab a line 
from there and expect it to look exactly 
the same in the source files.

	rasmus using beefylinuxbox ~ % grep -R 'paste(allowedMeshColor,' src/rgl
	src/rgl/R/mesh3d.R:    stop("'meshColor' must be one of: ", paste(allowedMeshColor, collapse = ", "))
	rasmus using beefylinuxbox ~ % grep -R 'pi - pi/nbarbs,' src/rgl
	1 rasmus using beefylinuxbox ~ % grep -R 'pi/nbarbs,' src/rgl
	src/rgl/R/arrow3d.R: phi <- seq(pi/nbarbs, 2*pi-pi/nbarbs, len = nbarbs)
	rasmus using beefylinuxbox ~ %

> > https://github.com/cran/rgl/blob/master/R/ashape3d.R
> 
> No, that's not it.  That file works 
> with mesh3d objects, but it has 
> nothing to do with arrows.

... I'm sorry, now I believe 
rgl::shade3d.mesh3d and rgl::arrow3d 
lives in 
https://github.com/cran/rgl/blob/master/R/mesh3d.R 
and 
https://github.com/cran/rgl/blob/master/R/arrow3d.R 
respectively.

Byron, there's a bunch of .cpp and .h 
files in 
https://github.com/cran/rgl/blob/master/src
you can look at to find the triangle or 
quadrilateral code you're interested in, 
I'm not quite sure what to look for 
there.

Best,
Rasmus



More information about the R-help mailing list