If you haven’t already, make sure to read Bob’s (@Transentia) massive improvement on the code from my last post. He made a lightly veiled piece of Java code really swing to a Groovy tune! He may also have gotten a little soiled playing with my piles!
Well, using Bob’s improvements with a little touch up (for densities and angles of repose), here’s a way to find out just how hard it would be to shift the mound of building material dropped on the end of your drive! Or, at least you can say how heavy it is and get someone else to shift it :-) .
enum Material {
CEMENT(131.0F, 45.0F),
DRYSAND(90.0F, 41.0F),
WETSAND(118.0F, 26.0F),
LOOSEGRAVEL(93.0F, 50.0F),
PACKEDGRAVEL(100.0F, 45.0F),
CLAY(120.0F, 43.0F)
Material(D, theta) {
this.D = D
this.theta = theta
}
def D
def theta
}
class ConicalPile {
def m
def h
def getWeightPounds() {
def cT = Math.cos(Math.toRadians(m.theta))
(Math.PI * h ** 3 * m.D) / (3 * (cT ** 2))
}
def getWeightTons() {
getWeightPounds() / 2000.0F
}
@Override
public String toString() {
"""$m
Weight(pounds): ${String.format("%.0f", getWeightPounds())}
Weight(tons): ${String.format("%.3f", getWeightTons())}"""
}
}
def testHt = 10.0F
println "At pile height of "+testHt+" foot"
for (Material m : Material.values())
println new ConicalPile(m: m, h: testHt)
which when run gives us something that looks quite reasonable
At pile height of 10.0 foot CEMENT Weight(pounds): 274366 Weight(tons): 137.183 DRYSAND Weight(pounds): 165467 Weight(tons): 82.734 WETSAND Weight(pounds): 152964 Weight(tons): 76.482 LOOSEGRAVEL Weight(pounds): 235709 Weight(tons): 117.855 PACKEDGRAVEL Weight(pounds): 209440 Weight(tons): 104.720 CLAY Weight(pounds): 234939 Weight(tons): 117.469



Pingback: Groovy coding a pile of dirt « LEXECORP
Pingback: Groovy Piles went mobile « LEXECORP