I should fill the area of a 400x100 square with random circles having random diameters between 20 and 1 (without overlap). Then, I need the output file of the generated coordinates. Can someone help me, please?

2 views (last 30 days)
M.Prasanna kumar
M.Prasanna kumar on 31 Jan 2019
Answered: M.Prasanna kumar on 31 Jan 2019
please some body help??
  2 Comments
Jan
Jan on 31 Jan 2019
Please mention the details: Are the random diameters the floating point values from 1 to 20, or the integers? Does "between" mean inclusively or exclusively? Are the random diameters distributed equally or normally or what? What is the format of the output file? How can a "400x100" be a square and not a rectangle? How many random circles do you want? Do you want the package with the maximum number for a given set of circles? Or are the centers set randomly also?
Currently your question does not contain enough details to be answered and you did not show, what you have tried so far. It sounds like you want the forum to solve your homework.

Sign in to comment.

Answers (3)

M.Prasanna kumar
M.Prasanna kumar on 31 Jan 2019
No sir, I dont know how to proceed?

M.Prasanna kumar
M.Prasanna kumar on 31 Jan 2019
All the random diameters i want is integers. sorry for the typo 400 * 100 is rectangle. yes i want package with maximum number of cirlcles.
pointsToPlace5 = 5000 ; % # of random coordinates we need to place
x5 = zeros(1, pointsToPlace5);
y5 = zeros(1, pointsToPlace5);
loopCounter5 = 1;
maxIterations5 = 200000; % Number of tries before giving up.
numberPlaced5 = 0; % No points placed yet.
while numberPlaced5 < pointsToPlace5 && loopCounter5 < maxIterations5
% Get new coordinate
xProposed5 = round((20 + (380-20)*rand()),0); %% random X- coordinates
yProposed5 = round((15 + (90-15)*rand()),0); %% random Y- coordinates
if loopCounter5 == 1
% First one automatically gets added of course.
numberPlaced5 = 1;
x5(numberPlaced5) = xProposed5;
y5(numberPlaced5) = yProposed5;
else
% Compute distance to all prior coordinates.
distances5 = sqrt((xProposed5-x5(1:numberPlaced5)).^2 +(yProposed5-y5(1:numberPlaced5)).^2);
% If less than 20, add it
if min(distances5 >= 2)
numberPlaced5 = numberPlaced5 + 1;
x5(numberPlaced5) = xProposed5;
y5(numberPlaced5) = yProposed5;
end
end
loopCounter5 = loopCounter5 + 1;
end
this code will generate random points which are at a distace of 2. but i want packing of circles with different radii (integers)

M.Prasanna kumar
M.Prasanna kumar on 31 Jan 2019
sorry to forum members, i am not expecting forum to solve completely. i'm expecting only help.
its my mistake , i didnt provide any details

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by