Do not think in terms of grids or cells! Coloring this plot is a purely algebraic problem, and I can completely describe it at the following high level of abstraction so that it'll work for any two (suitably smooth and close-enough-to-homeomorphic) parameterized surfaces, in any two coordinate systems, on any two distinct grids (perhaps even of different size). The beauty of **plot3d**'s syntax (especially the part related to color functions) is that it handles those grid-and-cell-level details for you in the background so that you can focus on the algebra.

Only the algebraic details matter here, so I'm no longer going to mention any topological (e.g., "homeomorphic") or analytic ("smooth") details. __The algebraic details that matter most are the number of input and output dimensions of __*all* of the following functions and the order in which those dimensions are given: the coordinate transformations, the parameterized surfaces, the projections, and the coloring functions.

Define a *3D coordinate system*** **as a surjective function *C: ***R**^{3 }-> **R**^{3} such that C(a, b, c) = <x(a,b,c), y(a,b,c), z(a,b,c)>, where <x, y, z> are the usual cartesian coordinates and <a, b, c> are the new *coordinates*. (In practice, most useful coordinate systems are named, predefined, and known to Maple, so we don't need to actually supply the function C.) Define a *parameterized **surface S in coordinates C* as a function S: A ->** R**^{3} such that S(u,t) = <a(u,t), b(u,t), c(u,t)>, where A is some 2D subset of **R**^{2}, <a, b, c> are the coordinates of C, and <u, t> are the *parameters *of *S*.

For the time being at least, I'll only use 1 color system; let's say HSV, because that's what I used for the final example. Like most color systems, it has 3 coordinates, which has nothing to do with geometry; rather, it's based on the biology of (the most-common version of) human retinae; other animals often have a different number of dimensions of color vision. Naturally, I'll call the coordinates of HSV <h, s, v> (hue, saturation, value). For the purpose of use with **plot3d**, all 3 are bounded in the interval 0..1^{[*2]}. Define a *coloring function F **for surface S *as F: A -> (0..1)^{3} such that F(u,t)= <h(u,t), s(u,t), v(u,t)>, where A, u, t are as they were defined for S.

Given two surfaces S1 defined on A1 and S2 defined on A2, define a *projection P from S2 to S1 *as a (sufficiently bijective) function from A2 to A1^{[*3]}. Note very carefully that the projections that I'm using here have 2 (not 3) input and output dimensions because surfaces are fundamentally 2D objects embedded in 3D space. Now let's say that we have S1, S2, and P (*from* S2 *to* S1), and we've decided on a coloring function F for S1. The algebraic trick that this entire article has been leading up to is that __The coloring function to use for S2 is the functional composition __**F@P**. It's as simple as that!

Now, onto your sphere-on-the-plane example. I chose to represent the sphere in spherical coordinates and the plane in cylindrical coordinates because that makes the algebra for all the functions easy enough to do in my head. For the sake of having 6 distinct^{[*1]} coordinate variables, I represent spherical coordinates as <rho, psi, phi> where rho is the radius, psi is the longitude (in range -Pi..Pi), and phi is the angle between the radial vector and the positive z-axis (in range 0..Pi); and cylindrical coordinates as <r, theta, z> (which I probably don't need to define for you). The surface functions and the projection from the plane to the sphere are

**Sph:= (psi, phi)-> <1, psi, phi>: **

Pl:= (r, theta)-> <r, theta, -1>:

P__pl_to_sph:= (r, theta)-> (theta, Pi-2*arctan(r)):

In other words, the projection is simply **psi = theta, phi = Pi - 2*arctan(r)**. [**Edit: **I now know that this is not the projection that you intended; however it still works as an example here, and my algebraic/functional formulation allows this one-line detail to be changed without changing anything else.] Note that it's essential to be consistent about the orders of the 2 *parameters* (..., ...) on the left sides of **->** and the orders of the 3 *coordinates* <..., ..., ...> on the right sides of **->**, and this is usually (for me at least) the most difficult part of working with alternate coordinate systems. (However, the vectors <...> could be changed to lists [...]; that makes no difference to (modern versions of) **plot3d**. Also, Maple's main plotting commands don't care what variable names you use for the coordinates in any coordinate system.) Furthermore, the order of the coordinates for any of Maple's predefined coordinate systems must be obeyed, although it's poorly documented.

For the coloring function of the sphere, I'm using

**Color__sph:= (psi, phi)->**

COLOR(HSV, (psi/Pi+1)/2., 1.-phi/Pi, 1.-phi/Pi) #note the decimal points

:

I expect that you'll make that more elaborate, but it's the only one of these functions that you should change. [**Edit: **See the **Edit** comment in the previous paragraph.] Finally, the plotting command is

**plots:-display(
plot3d~(
[Sph(psi, phi), Pl(theta, r)],
[psi, theta]=~ -Pi..Pi, [phi= 0..Pi, r= 0..4],
coords=~ [spherical, cylindrical],
color=~ [
Color__sph(psi, phi),
(Color__sph @ P__pl_to_sph)(r, theta)
]
),
lightmodel= none, scaling= constrained, axes= none,
viewpoint= circleleft
);**

I've tried several times to upload the resulting animation as a GIF file, but MaplePrimes is having a problem with that.

[*1] It's not actually necessary that the coordinate names between the coordinate systems be distinct. Making them distinct simply helps with my mental organization of the problem.

[*2] Bounding the color coordinates in the interval 0..1 is not strictly required. Maple will usually normalize the values for you. However, I don't like to rely on that; sometimes I've had problems if I don't normalize them myself.

[*3] This is perhaps not a standard definition of *projection*, and it's certainly not how that word is used in linear algebra, but it does conform both to the way that you've already used the term (as in "stereographic projection") and to how it's used in relation to geographic maps.