I have an assessment due at midnight tonight and I have left

I have an assessment due at midnight tonight and I have left it really late and having next to no understanding of how to get the required answer has made me quite nervours as I need to do well. As this is an online course we are not exactly properly taught the content before the questions/assessments are due to be completed making it extra difficult. The question that I need to do is as follows;

In this assignment you will create a road combination finder function called showRoads(picture).

the \'picture\' that is given to the function is an image with a solid white background and has an arbitrary number of black dots (pixels).

one example instance of Example of input:

The image below is 480x360 pixels (the border is drawn for clarit only) and has (4) black dots:

Cannot copy picture across however the black dots are at locations: (134,90) (120,196) (228,233) (360,149).

Your function must first detect black dots (pixels) on the image. An image can have zero or more.

Then your function must draw lines using the addLine function in JES to show all the combinations of connections that could be made for the original input picture. In each combination, the lunes must not have disconnections. Each combination shoud be down on a separate image (hint:creare a copy of the original input image).

Finally you must print the lengths of the lines for each combination. The distance between any two points (say x1,y1 and x2,y2) can be calculated using the following formula:

distance_between_two_points = sqrt(pow(x1-x2,2)+pow(y1-y2,2))

For example, in the three example combinations shown above (also could not copy), the distance of the entire line can be calculated as a sum of its 3 smaller segments (d1,d2 and d3):

d1 = sqrt(pow(120-134,2)+pow(196-90,2)) = 106.92053123698928

d2 = sqrt(pow(134-228,2)+pow(90-233,2)) = 171.1286066091815

d3 = sqrt(pow(228-360,2)+pow(233-149,2)) = 156.46085772486356

total_distance = d1+d2+d3 = 434.5099955710343

Your code must work for any number of lune segments, not just for 3. I.e. he image can have any number of black dots (pixels) and you must try all combinations of lines tha go through each dot.

Any help is greatly appreciated.

Solution

addArc(picture, startX, startY, width, height, start, angle[, color]): picture: the picture you want to draw the arc on startX: the x-coordinate of the center of the arc startY: the y-coordinate of the center of the arc width: the width of the arc height: the height of the arc start: the start angle of the arc in degrees angle: the angle of the arc relative to start in degrees color: the color you want to draw in (optional) Takes a picture, (x,y) coordinates, width, height, two integer angles, and (optionally) a color as input. Adds an outline of an arc starting at (x,y) at an initial angle of \"start\" with the given width and height. The angle of the arc itself is \"angle\", which is relative to \"start.\" Default color is black. addArcFilled addArcFilled(picture, startX, startY, width, height, start, angle[, color]): picture: the picture you want to draw the line on startX: the x position you want the arc to start startY: the y position you want the arc to start width: the width of the arc height: the height of the arc start: the start angle of the arc in degrees angle: the angle of the arc relative to start in degrees color: the color you want to draw in (optional) Takes a picture, (x,y) coordinates, width, height, two integer angles, and (optionally) a color as input. Adds a filled arc starting at (x,y) at an initial angle of \"start\" with the given width and height. The angle of the arc itself is \"angle\", which is relative to \"start.\" Default color is black. addLine addLine(picture, startX, startY, endX, endY[, color]): picture: the picture you want to draw the line on startX: the x position you want the line to start startY: the y position you want the line to start endX: the x position you want the line to end endY: the y position you want the line to end color: the color you want to draw in (optional) Takes a picture, a starting (x, y) position (two numbers), and an ending (x, y) position (two more numbers, four total), and (optionally) a color as input. Adds a line from the starting point to the ending point in the picture. Default color is black. addOval addOval(picture, startX, startY, width, height[, color]): picture: the picture you want to draw the rectangle on startX: the x-coordinate of the upper left-hand corner of the bounding rectangle of the oval startY: the y-coordinate of the upper left-hand corner of the bounding rectangle of the oval width: the width of the oval height: the height of the oval color: the color you want to draw in (optional) Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds an oval outline of the given dimensions using the (x,y) as the upper left corner of the bounding rectangle. Default color is black. addOvalFilled addOvalFilled(picture, startX, startY, width, height[, color]): picture: the picture you want to draw the rectangle on startX: the x-coordinate of the upper left-hand corner of the bounding rectangle of the oval startY: the y-coordinate of the upper left-hand corner of the bounding rectangle of the oval width: the width of the oval height: the height of the oval color: the color you want to draw in (optional) Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds a filled oval of the given dimensions using the (x,y) as the upper left corner of the bounding rectangle. Default color is black. addRect addRect(picture, startX, startY, width, height[, color]): picture: the picture you want to draw the rectangle on startX: the x-coordinate of the upper left-hand corner of the rectangle startY: the y-coordinate of the upper left-hand corner of the rectangle width: the width of the rectangle height: the height of the rectangle color: the color you want to draw in (optional) Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds a rectangular outline of the specified dimensions using the (x,y) as the upper left corner. Default color is black. addRectFilled addRectFilled(picture, startX, startY, width, height[, color]): picture: the picture you want to draw the rectangle on startX: the x-coordinate of the upper left-hand corner of the rectangle startY: the y-coordinate of the upper left-hand corner of the rectangle width: the width of the rectangle height: the height of the rectangle color: the color you want to draw in (optional) Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds a filled rectangle of the specified dimensions using the (x,y) as the upper left corner. Default color is black. addText addText(picture, xpos, ypos, text[, color]): picture: the picture you want to add the text to xpos: the x-coordinate where you want to start writing the text ypos: the y-coordinate where you want to start writing the text text: string containing the text you want written color: the color you want to draw in (optional) Takes a picture, an x position and a y position (two numbers), and some text as a string, which will get drawn into the picture, in the specified color. Default is black. addTextWithStyle addTextWithStyle(picture, xpos, ypos, text, style[, color]): picture: the picture you want to add the text to xpos: the x-coordinate where you want to start writing the text ypos: the y-coordinate where you want to start writing the text text: string containing the text you want written style: the font style you want to draw in (See makeStyle) color: the color you want to draw in (optional) Takes a picture, an x position and a y position (two numbers), and some text as a string, which will get drawn into the picture, in the given font style and specified color. Default is black. copyInto copyInto(smallPicture, bigPicture, startX, startY): smallPicture: the picture to paste into the big picture bigPicture: the picture to be modified startX: the X coordinate of where to place the small picture on the big one startY: the Y coordinate of where to place the small picture on the big one Takes two pictures, a x position and a y position as input, and modifies bigPicture by copying into it as much of smallPicture as will fit, starting at the x,y position in the destination picture
I have an assessment due at midnight tonight and I have left it really late and having next to no understanding of how to get the required answer has made me qu
I have an assessment due at midnight tonight and I have left it really late and having next to no understanding of how to get the required answer has made me qu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site