- #1
Eng_physicist
- 30
- 0
Homework Statement
I have to do a monte carlo approximation for the Volume of the CN tower for my assignment
but I don't know what size to make the cubes and for the part below the main pod I do not know how to create a tapered tower for loop that gets smaller with each loop so that the coordinates stay with in the triangle any help would be good this is what I have so far
Homework Equations
V=h*pi*(r)^2
The Attempt at a Solution
This the code my proff gave us(which has some of the dimension and he gave us the random coordinate generator plus the if statement for the pod, the rest is mine) to start plus my own modification I having trouble knowing if I did the monte carlo method correctlyheight =553.33;
heightroof=457.2;
tapoured_height=342;
base_diameter=66.6;
pod_baseh=200;
pod_toph=250;
n_trials=1e4;
counter=0;
Vpod=0;% volume pod
Vtaop=0;%volume tapered tower
vc=(1/n_trials)^3; %volume of cube
base_tapered=66.6;
coords=rand(n_trials,3);
coords(:,3)=coords(:,3)*height;%scale z coordinates
coords(:,1:2)=(coords(:,1:2)-.5)*pod_diametere;%scale z coordinates
known_volume=height*(base_diametere^2)/4;
%loop to check points
for i=1:n_trials;
%for pod
if coords(i,3)>pod_baseh && coords(i,3)<pod_toph
if sqrt(coords(i,1))^2 +(coords(i,2))^2<(pod_diameter/2)
counter=counter+1;
Vpod = Vpod+ sum(vc);
end
else
%for tapered tower
%%code to check if coords falls with in tapoured tower
if coords(i,3)>0 && coords(i,3)<tapoured_height
if sqrt(coords(i,1))^2 +(coords(i,2))^2<(base_tapered/2)
base_tapered = ( base_tapered)/n_trials;
Vtap = Vtap+ sum(vc);
end
end
end
end
V=Vpod+Vtap; % volume total