Drawing spherical wedges with rgl

Posted on February 22, 2018 by Stéphane Laurent
Tags: R, graphics

This post provides some code to draw a sphere wedge with the R library rgl.

As an helper function, I use spherical2cartesian to convert from spherical coordinates to Cartesian coordinates:

Now, here is the main function:

A simple example:

Now let’s draw a tricolor sphere:

As you can see, I use 2*pi and not 0 for the blue wedge. That should be equivalent. However, and I don’t know why, using 0 instead of 2*pi colors the interior of the two other wedges:

Spherical triangles with rgl

I also did a code which draws spherical triangles for rgl. I won’t reproduce it here. If you are interested, it is available in this gist.