# Impact Crater Simulation

I have been trying to model crater formation on a given planetary surface - $500\,\textrm{km}^2$. The locations of impacts are random, however, if an impact is within $30\,\textrm{km}$ of another, the previous crater is considered eliminated.

So far I have used RandomReal[0,500] for both the $x$ any $y$ coordinate values on the $500\,\textrm{km}^2$ plot. My problem is that the arrangement of craters changes for every evaluation I do. What I'm looking to achieve is a cumulation of craters, one by one."Drawn on" so to speak. This way, appropriate crater destruction can also ensue.

I am also still trying to figure out a way to model crater destruction. As I mentioned, if an impact location is within $30\,\textrm{km}$ of another, the previous crater is eliminated. I tried using If[EuclideanDistance[],...] but no luck.

The code I used for crater location (points) is:

    craterlocations = Table[{RandomReal[{0, 500}], RandomReal[{0, 500}]}, {n}]
p1 = ListPlot[craterlocations]


I need to produce a similar plot, but the craters should continually form. As of now I will always wind up with a different random arrangement for each number of impacts (n).

• Can you post your code so we'll have a starting point? Also are your craters just circles in the graphics? Nov 17, 2013 at 0:59
• @VitaliyKaurov , for the purpose of modeling, points work fine. A crater is considered destroyed when its center is covered by a new one. That translates to a point proximity of 30km (crater radius). Nov 17, 2013 at 1:48
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign Nov 17, 2013 at 2:05

Very similar to Vitaliy's answer, but deleting all craters within the critical distance, and somewhat more compact:

craters = {{0, 0}};
number = {1};
Dynamic[
(craters = #;
Row[{
Graphics[{[email protected], Point@#}, ImageSize-> 230,  PlotRange-> 300, Frame-> True],
ListLinePlot[AppendTo[number, Length@#], PlotRange -> All,
ImageSize -> {Automatic, 210}, Frame -> True]}]) &@
(Join[{#},Complement[craters, Nearest[craters, #, {∞,30}]]]&@ RandomReal[250{-1, 1}, 2])
]


• +1 very neat, is example of this syntax {Infinity, 30} in documentation on Nearest? Nov 18, 2013 at 2:44
• @VitaliyKaurov I used this reference.wolfram.com/mathematica/tutorial/UsingNearest.html, and probably some remembrance of a previous answer in this site Nov 18, 2013 at 3:06

This is simplest implementation. If a new crater gets closer than 30 to some old craters, only closest old crater is getting replaced with new one. You can built on this example something more sophisticated.

craters = {{0, 0}};
number = {1};
Dynamic[new = RandomReal[{-250, 250}, 2];
near = Nearest[craters, new][[1]];

Row[{
Graphics[{PointSize[.05],
Point[craters =
If[EuclideanDistance[near, new] < 30,
craters[[Position[craters, near][[1, 1]]]] = new; craters,
craters~Join~{new}]]}, ImageSize -> 230, PlotRange -> 300,
Frame -> True],

ListPlot[number = number~Join~{Length[craters]},
ImageSize -> {Automatic, 210}, Frame -> True]
}]
]


• Vitaliy, Thanks for the help. This is what I was going for. How could I find the number of craters after a certain time step? In other words, if a crater hits every 1000 years, how could I see the number of craters (or density) as a function of time? I don't see anything related to the rate or number of impacts in the code. Nov 17, 2013 at 2:06
• @BenjaminL Updated. History is stored in variable 'number'. Nov 17, 2013 at 2:32