Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started