Question: Extend the GUI with an additional function to be applied to Task 1 needle dropping: 1 . It should allow the user to select a
Extend the GUI with an additional function to be applied to Task needle dropping:
It should allow the user to select a needle by clicking on or near it with the mouse. The needle will then be highlighted in a different colour.
The n needles with most similar orientation will then be highlighted in yet another colour. The default value is n and the value of n can be modified through the GUI.
this the code for task code:
"function p crossings, allLines, allverticescounters BuffonStandardPiPlotwidth length, throws, floorboards
crossings ;
allLines cellthrows; Initialize the cell array
allverticescounters cellthrows;
for i:throws
vertexcounter ;
centerX rand width floorboards;
centerY randwidthfloorboards ;
rotationAngle randpi;
Genereating vertices of the lines
lineVertices centerX length cosrotationAngle centerY length sinrotationAngle;
centerX length cosrotationAngle centerY length sinrotationAngle; ;
allLinesi lineVertices; Store the generated line vertices
leftside floorcenterXwidth width;
rightside leftside width;
Check every vertex whether crossed the vertical line or not
vertexcounter sumlineVertices: rightside lineVertices: leftside vertexcounter;
allverticescountersi vertexcounter;
crossings crossings sumvertexcounter ~;
end
p length throwscrossings width;
dispEstimated p: numstrp;
dispNumber of needles that crossed a crack: numstrcrossings
end
and this is the GUI code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
