Given four RED,GREEN,BLUE,YELLOW cylinders with radius 1 each having a center line the diagonal of a cube with a volume of 64. Find their volume of intersection. Use GeoGebra or any other Graphics package to solve the problem.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This is the Steinmetz solid formed by four cylinders of radius 1 aligned in the directions of the four altitudes of a regular tetrahedron. Its volume is 1 2 ( 2 2 − 6 ) .
The volume can computed by a triple integral
Volume = ∫ x = − 2 2 ∫ y = − 2 2 ∫ z = − 2 2 f ( x , y , z ) d z d y d x
where,
f ( x , y , z ) = { 1 , 0 , if ( x , y , z ) is inside all cylinders . otherwise .
The integral evaluates to ≈ 4 . 5 5 2
Here's the code for the integral and the function, written in Visual Basic.
' ====== Triple Integration using Simpson's method ========
Public Function integrate3d(ByVal a1 As Double, ByVal b1 As Double, ByVal a2 As Double, ByVal b2 As Double, ByVal a3 As Double, ByVal b3 As Double) As Double
Dim isum As Double
Dim i, j, k, l As Integer
Dim x, y, z, w As Double
isum = 0
n1 = 200
n2 = 200
n3 = 200
h1 = (b1 - a1) / n1
For i = 0 To n1
x = a1 + i * h1
If i = 0 Or i = n1 Then
ci = 1
ElseIf i Mod 2 = 1 Then
ci = 4
Else
ci = 2
End If
h2 = (b2 - a2) / n2
For j = 0 To n2
y = a2 + j * h2
If j = 0 Or j = n2 Then
cj = 1
ElseIf j Mod 2 = 1 Then
cj = 4
Else
cj = 2
End If
h3 = (b3 - a3) / n3
For k = 0 To n3
If k = 0 Or k = n3 Then
ck = 1
ElseIf k Mod 2 = 1 Then
ck = 4
Else
ck = 2
End If
z = a3 + k * h3
isum = isum + ci * cj * ck * h1 * h2 * h3 * f3d(x, y, z)
Next k
Next j
Next i
isum = isum / 27
integrate3d = isum
End Function
'=================== Function of three variables ============================
Public Function f3d(ByVal x As Double, ByVal y As Double, ByVal z As Double) As Double
Dim umat(3, 4) As Double
Dim l(3), r(3) As Double
Dim rp(3) As Double
Dim v1(3) As Double
Dim dl(3) As Double
Dim u(3) As Double
umat(1, 1) = 1
umat(2, 1) = 1
umat(3, 1) = 1
umat(1, 2) = 1
umat(2, 2) = 1
umat(3, 2) = -1
umat(1, 3) = 1
umat(2, 3) = -1
umat(3, 3) = 1
umat(1, 4) = -1
umat(2, 4) = 1
umat(3, 4) = 1
For j = 1 To 4
For i = 1 To 3
u(i) = umat(i, j)
Next i
unorm = Sqr(3)
rp(1) = x
rp(2) = y
rp(3) = z
rpnorm = norm(rp, 3)
' now we want find the distance of (x, y, z) from the line u
rproj = dot(rp, u) / unorm
rortho = rpnorm ^ 2 - rproj ^ 2
If rortho < 0 Then rortho = 0
rortho = Sqr(rortho)
If rortho > 1 Then
f3d = 0
Exit Function
End If
Next j
f3d = 1
End Function
'============== Dot product function =========================
Public Function dot(x, y)
dot = x(1) * y(1) + x(2) * y(2) + x(3) * y(3)
End Function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
Problem Loading...
Note Loading...
Set Loading...
Below you will find my C++ code using multithreading. Due to the symmetry, I performed the computation on one of the octants and multiplied the result by 8 .