3
$\begingroup$

I'm working on a set of diagrams to try to make interesting math activities for positive and negative integers. These diagrams look like this.

3D illusion, 4 bumps and 3 dimples.

(This diagram would represent 4-3=1. Later, I'll test this out to see if students actually see it this way.)

What I'd like to do is to create animations where the bumps and dimples combine and become a 'flat' surface.

My first attempt is just to have gray in the overlap zone, which isn't too bad.
enter image description here

What I'd like is to have the overlap zone more gradually transition from the bump through to the dimple.


Here's the basic Mathematica code I used to create these images.
Unit[θ_] := {Cos[θ], Sin[θ]}

Dimple[r_, ϕ_] := Translate[Polygon[Table[Unit[θ], {θ, 0, 360*Degree, 
(360*Degree)/80}], VertexColors -> Table[Blend[{White, Black}, (1 + Sin[θ])/2], {θ, 0, 
360*Degree, (360*Degree)/80}]], r*Unit[ϕ]]

Bump[r_, ϕ_] := Translate[Polygon[Table[Unit[θ], {θ, 0, 360*Degree, 
(360*Degree)/80}], VertexColors -> Table[Blend[{Black, White}, (1 + Sin[θ])/2], {θ, 0, 
360*Degree, (360*Degree)/80}]], r*Unit[ϕ]]

OverLapTable[d_] := Join[Table[Unit[θ] - {d, 0}, {θ, -ArcCos[d], ArcCos[d], 0.01}],  
Table[Unit[θ] + {d, 0}, {θ, 180*Degree - ArcCos[d], 180*Degree + ArcCos[d], 0.01}]]

Graphics[{Gray, Rectangle[{-2, -2}, {2, 2}], Bump[0.5, 0], Dimple[0.5, 180*Degree], Gray, 
Polygon[OverLapTable[0.5]]}]

Additional

This sort of a side view of what I'm hoping to accomplish, enter image description here

with a smooth transition between the dimple and the bump.

$\endgroup$
1
  • $\begingroup$ Thanks for cleaning up the code, wuyud! I didn't know how to do that. $\endgroup$ – David Elm Dec 21 '20 at 4:37
1
$\begingroup$

One can try Opacity:

Graphics[{{Gray, Rectangle[{-2, -2}, {2, 2}]}, {Opacity[0.9], 
   Bump[0.5, 0]}, {Opacity[0.9], Dimple[0.5, 180*Degree]}}]

enter image description here

$\endgroup$
1
  • $\begingroup$ That's not bad, but I was hoping for something that would transition a little better. $\endgroup$ – David Elm Dec 21 '20 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.