Jump to content

Draw a sphere: Difference between revisions

Line 4,089:
}
 
for (i <- math.floor(-r).toInt to Mathmath.ceil(r).toInt; x = i + .5)
println(
(for (j <- math.floor(-2 * r).toInt to Mathmath.ceil(2 * r).toInt; y = j / 2.0 + .5)
yield if (x * x + y * y <= r * r) {
 
Line 4,105:
 
private def normalize(v: Array[Double]): Array[Double] = {
val len = Mathmath.sqrt(v.head * v.head + v(1) * v(1) + v.last * v.last)
v.map(_ / len)
}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.