This problem uses subscripts and superscripts which may not display properly for plugin users.
You are to create a class DogWoods, with a method howFar, which takes ints containing the x and y coordinates, and the diameters of each tree. The method will also take parameters startx and starty, which are the starting x and y coordinates for the dog. The ith element of x corresponds to the ith element of y, which corresponds to the ith element of diameter. The dog is determined to have reached the center of the woods when the dog's distance to the center is <= 10 units. Your method must return the distance that would be travelled by the dog, while obeying his nature, before he reaches the center of the woods. Your return value must be within 1e-9 relative or absolute error of the correct value.
The location (0,0) is the center of the woods, with the positive x axis extending to the right, and the positive y axis extending up (a standard Cartesian plane).
If the dog would run an infinitely long distance while obeying his nature, then your method should return -1.
Given two circles with the following equations,(x - x0)2 + (y - y0)2 = r02 (A circle centered at (x0,y0) with radius r0)
x2 + y2 = r12 (A circle centered at (0,0) with radius r1)
their points of intersection are given by:
x = x0 / 2 - x0(r02 - r12) / 2d + y0p / 2d
|-||The dog will always obey his nature as described.|
|-||The dog may not run through any part of a tree.|
|-||Trees are to be considered exactly round.|
|-||The dog should be treated as a mathematical point. I.e., it has no diameter.|
|-||The distance around a circle is pi * diameter.|
|-||pi ~ 3.14159265358979.|
|-||x, y, and diameter will all have the same number of elements.|
|-||x will have between 1 and 50 elements, inclusive.|
|-||Every element of x and y will be between -1000 and 1000, inclusive.|
|-||Every element of diameter will be between 1 and 100, inclusive.|
|-||startx and starty and will be between -1000 and 1000, inclusive.|
|-||The closest that the perimeter of any two trees will be to each other is 1e-6.|
|-||For any two trees a and b, the distance of the closest point to the center of a will not be within 1e-6 of the distance of the furthest point to the center of b.|
|-||No tree will completely cover the circle of diameter 20 at the center of the woods.|
|-||For every tree, the circle of diameter 20 will either not intersect that tree, or it will intersect by at least 1e-6 units at the greatest width of intersection.|
|-||The dog will not start in the midst of a tree.|