Question
IN PYHTON PLEASE NEEDS TO BE SOLVED ASAP AND I AM SO LOST PLEASE HELP it is due soon please help me :( thank you
IN PYHTON PLEASE NEEDS TO BE SOLVED ASAP AND I AM SO LOST PLEASE HELP it is due soon please help me :( thank you so much.
The given code is as follows
import numpy as np def a( d1, d2, x1, y1, x2, y2 ): numerator=d1**2-d2**2 - ((x1**2+y1**2)-(x2**2+y2**2)) denominator=2*(y2-y1) return numerator/denominator
def b( x1, y1, x2, y2 ): return -(x2-x1)/(y2-y1)
def solve_xy( x1, y1, x2, y2, d1, d2 ): bb=b(x1,y1,x2,y2) aa=a(d1,d2,x1,y1,x2,y2) rad=4*(bb*(aa-y1)-x1)**2 - 4*(1+bb**2)*(x1**2-d1**2+(y1-aa)**2) pre=2*(x1-bb*(aa-y1)) den=2*(1+bb**2) xp=(pre+np.sqrt(rad))/den xm=(pre-np.sqrt(rad))/den yp=aa+xp*bb ym=aa+xm*bb return xm,ym,xp,yp
10.25 LAB: Triangulation Triangulation is the process of locating an unknown point given two known points and distances from those known points. Consider two points (x, and (x22). Let (xy) be an unknown point whose distances to points 1 and 2 dy and d, respectively, are known. The Pythagorean theorem allows us to express x and y (the coordinates of the unknown point) in terms of (xy) (x2y2).d, and d2 Inverting these two formulae to make them explicit in x and y is really a lot of fun, but it takes a while. Here is the final result bia and 2(372-h y2-y1 Note that the two possible values for X, Xt, and X. arise from the positive and negative sense of the square root, and the value of y derives from its particular x. So because of the power of 2 in the Pythagorean theorem, we find that there are two possible points, x y and (x, y ), that are each di from (x, y) and d2 from (xa y2). Triangulation" refers to the fact that we need a third known point to decide which of (x, y4) and (x, y) is our sought-after point. So long as that third point (Kg 3), is closer to (x %) than it is to (c, y) (or vice versa), we can choose the final unknown point to be the one that is closer to (x3 y3) These formulae can be expressed as functions import numpy as np def a( dl, d2, x1, yl, x2, y2) numerator-dl**2-d2**2 ((xl**2+yl*2) - (x2* *2+y2**2)) denominator-2 (y2-yl) return numerator/denominator def b( x1, yl, x2, y2) return- (x2-xl)/ (y2-yl) def solve_xy xl, yl, x2, y2, di, d2: bb-b (x1,yl, x2,y2) aa-a (dl, d2, x1,yl, x2, y2) rad-4 (bb (aa-yl)-x1) **2 -4 (1+bb**2) (xl* *2-dl2 (yl-aa) **2) pre-2* (xl-bb (aa-yl)) den-2* (1+bb 2) xp-(pre+np. sqrt (rad)) /den xm (pre-np.sqrt (rad)) /den return xm , ym, xp, yp Consider that point 1 is a distance of 4.1 (arbitrary units) from the unknown point with (xi,y distance of 3.8 from the unknown point with (x2 y2) coordinates of (-1.9,-1.9) coordinates of (2.4,1.8) and that point 2 is a 1. Use the functions above to determine two potential sets of coordinates (Yn) or (m ym) for the unknown point To check this calculation, use a point-to-point distance calculation (for which Pythagoras gets credit) to determine if the same given distance can be calculated using the original known coordinates and the (Yo yo) or (m ym) coordinates. 2. Define a function called pythagoras that takes as arguments the coordinates of two points (e.g, for a and b, (xa, ya, xb, yb)) and returns the distance between the two points. 3. Use pythagoras to determine if the calculated distances of point 1 from (p y) and (m ym) are equivalent. Do the same for point 2 Now, to properly call this 'triangulation to locate a single point, we need a third point as a reference. We need not specify the distance from the unknown point to this third; we merely choose the resulting point that is closer to this third reference point 3 Write a function called triangulate that takes as arguments the potential coordinates of the unknown point op Ye) and (Km m) followed by the coordinates of the reference point and returns the coordinates of the point cosest tot e third point. The point closest to the reference point will be taken to be the unknown location. main.py Load default template... 1 import numpy as np 2 def aC d1, d2, x1, yl, x2, y2 ): 4 6 numerator-d1**2-d2* *2 ((x1**2+y1* *2)-(x2**2+y2**2)) denominator-2*(y2-yl) return numerator/denominator 7 def b x1, yl, x2, y2: return -(x2-x1)/(y2-y1) 10 def solve_xyC x1, yl, x2, y2, d1, d2 ): 11 bb-b(x1,y1,x2,y2) 12 aa-a(d1,d2,x1,y1,x2,y2) 13 14 15 den-2*(1+bb**2) 16 xp-(pre+np.sqrt(rad))/dern 17 xm-(pre-np.sqrt(rad))/den 18 pre-2*(x1-bb*(aa-yl)) denominator-2 (y2-y1) return numerator/denominator 7def b x1, yl, x2, y2 : return -(x2-x1)/(y2-y1) def solve_xyC x1, yl, x2, y2, d1, d2 ): bb-b(x1,y1,x2,y2) aa-a(d1,d2,x1,y1,x2,y2) pre-2*(x1-bb*(aa-y1)) den-2*(1+bb**2) xp-(pre+np.sqrt(rad))/den xm-(pre-np.sqrt(rad))/den -"bb ym-aa+xm*bb return xm , ym , xp, yp 10.25 LAB: Triangulation Triangulation is the process of locating an unknown point given two known points and distances from those known points. Consider two points (x, and (x22). Let (xy) be an unknown point whose distances to points 1 and 2 dy and d, respectively, are known. The Pythagorean theorem allows us to express x and y (the coordinates of the unknown point) in terms of (xy) (x2y2).d, and d2 Inverting these two formulae to make them explicit in x and y is really a lot of fun, but it takes a while. Here is the final result bia and 2(372-h y2-y1 Note that the two possible values for X, Xt, and X. arise from the positive and negative sense of the square root, and the value of y derives from its particular x. So because of the power of 2 in the Pythagorean theorem, we find that there are two possible points, x y and (x, y ), that are each di from (x, y) and d2 from (xa y2). Triangulation" refers to the fact that we need a third known point to decide which of (x, y4) and (x, y) is our sought-after point. So long as that third point (Kg 3), is closer to (x %) than it is to (c, y) (or vice versa), we can choose the final unknown point to be the one that is closer to (x3 y3) These formulae can be expressed as functions import numpy as np def a( dl, d2, x1, yl, x2, y2) numerator-dl**2-d2**2 ((xl**2+yl*2) - (x2* *2+y2**2)) denominator-2 (y2-yl) return numerator/denominator def b( x1, yl, x2, y2) return- (x2-xl)/ (y2-yl) def solve_xy xl, yl, x2, y2, di, d2: bb-b (x1,yl, x2,y2) aa-a (dl, d2, x1,yl, x2, y2) rad-4 (bb (aa-yl)-x1) **2 -4 (1+bb**2) (xl* *2-dl2 (yl-aa) **2) pre-2* (xl-bb (aa-yl)) den-2* (1+bb 2) xp-(pre+np. sqrt (rad)) /den xm (pre-np.sqrt (rad)) /den return xm , ym, xp, yp Consider that point 1 is a distance of 4.1 (arbitrary units) from the unknown point with (xi,y distance of 3.8 from the unknown point with (x2 y2) coordinates of (-1.9,-1.9) coordinates of (2.4,1.8) and that point 2 is a 1. Use the functions above to determine two potential sets of coordinates (Yn) or (m ym) for the unknown point To check this calculation, use a point-to-point distance calculation (for which Pythagoras gets credit) to determine if the same given distance can be calculated using the original known coordinates and the (Yo yo) or (m ym) coordinates. 2. Define a function called pythagoras that takes as arguments the coordinates of two points (e.g, for a and b, (xa, ya, xb, yb)) and returns the distance between the two points. 3. Use pythagoras to determine if the calculated distances of point 1 from (p y) and (m ym) are equivalent. Do the same for point 2 Now, to properly call this 'triangulation to locate a single point, we need a third point as a reference. We need not specify the distance from the unknown point to this third; we merely choose the resulting point that is closer to this third reference point 3 Write a function called triangulate that takes as arguments the potential coordinates of the unknown point op Ye) and (Km m) followed by the coordinates of the reference point and returns the coordinates of the point cosest tot e third point. The point closest to the reference point will be taken to be the unknown location. main.py Load default template... 1 import numpy as np 2 def aC d1, d2, x1, yl, x2, y2 ): 4 6 numerator-d1**2-d2* *2 ((x1**2+y1* *2)-(x2**2+y2**2)) denominator-2*(y2-yl) return numerator/denominator 7 def b x1, yl, x2, y2: return -(x2-x1)/(y2-y1) 10 def solve_xyC x1, yl, x2, y2, d1, d2 ): 11 bb-b(x1,y1,x2,y2) 12 aa-a(d1,d2,x1,y1,x2,y2) 13 14 15 den-2*(1+bb**2) 16 xp-(pre+np.sqrt(rad))/dern 17 xm-(pre-np.sqrt(rad))/den 18 pre-2*(x1-bb*(aa-yl)) denominator-2 (y2-y1) return numerator/denominator 7def b x1, yl, x2, y2 : return -(x2-x1)/(y2-y1) def solve_xyC x1, yl, x2, y2, d1, d2 ): bb-b(x1,y1,x2,y2) aa-a(d1,d2,x1,y1,x2,y2) pre-2*(x1-bb*(aa-y1)) den-2*(1+bb**2) xp-(pre+np.sqrt(rad))/den xm-(pre-np.sqrt(rad))/den -"bb ym-aa+xm*bb return xm , ym , xp, ypStep 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