My favorite functions: Manipulate and Graphics
My favorite functions: Manipulate and Graphics
I am working as a software developer in the field of geometric computation. I love to visualize some aspects of algorithms, which I am working on. This helps me to fully understand the subject and to get some intuition for singular conditions. I do also use those visualizations to explain my solutions to collegues and customers.
Locators are particularly useful to interact with 2D Graphics. I have used them to being able to move circle centers and lines in the following examples. Just grab the center points to move them. In the latter examples, locators are rendered as colored dots. They can still be moved interactively.
I am not including the code for all examples, since this would be repetitive. To be able to just copy the manipulation cell, I did use the option “SaveDefinitions”. This ensures that I don’t need to define all external symbols I used inside of Manipulate in my presentation document.
The experience on desktop is great. In a web browser it is somewhat limited, because drawing lags a bit, but it is still useful.
All circles tangential to two circles
All circles tangential to two circles
Intersections of parallel curves are the centers of touching circles.
Manipulate[Module[{blueInner,blueCircle,blueOuter,greenInner,greenCircle,greenOuter,intersections,ϵ},ϵ=10^-7;blueInner=Rationalize[Circle[blueCenter,If[blueRadius>offset,blueRadius-offset,blueRadius+offset]],ϵ];blueCircle=Rationalize[Circle[blueCenter,blueRadius],ϵ];blueOuter=Rationalize[Circle[blueCenter,blueRadius+offset],ϵ];greenInner=Rationalize[Circle[greenCenter,If[greenRadius>offset,greenRadius-offset,greenRadius+offset]],ϵ];greenCircle=Rationalize[Circle[greenCenter,greenRadius],ϵ];greenOuter=Rationalize[Circle[greenCenter,greenRadius+offset],ϵ];intersections={x,y}/.Join[Solve[{x,y}∈blueOuter&&{x,y}∈greenOuter,{x,y}],Solve[{x,y}∈blueOuter&&{x,y}∈greenInner,{x,y}],Solve[{x,y}∈blueInner&&{x,y}∈greenOuter,{x,y}],Solve[{x,y}∈blueInner&&{x,y}∈greenInner,{x,y}]];intersections=If[MatchQ[intersections,{_Symbol,_Symbol}],{},intersections];Graphics[{Blue,blueCircle,Dotted,blueOuter,blueInner,Dashing[{}],Green,greenCircle,Dotted,greenOuter,greenInner,Dashing[{}],Red,Point/@intersections,Circle[#,offset]&/@intersections},ImageSizeFull]],{{offset,1,"Red radius"},0.5,5},{{blueRadius,4,"Blue radius"},1,10},{{greenRadius,5,"Green radius"},1,10},{{blueCenter,{0,0}},Locator},{{greenCenter,{5,4}},Locator},SaveDefinitionsTrue]
Out[]=
All circles tangential to a circle and a line
All circles tangential to a circle and a line
Out[]=
Pole and polar
Pole and polar
Out[]=
All tangent lines to two circles
All tangent lines to two circles

