Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, could you help me to solve this question? I'm lost...In python please 10.25 LAB: Triangulation Triangulation is the process of locating an unknown point
Hi, could you help me to solve this question? I'm lost...In python please
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 (x1y1) and (x2y2) Let (xy) be an unknown point whose distances to points 1 and 2 d1 and d2, respectively, are known. The Pythagorean theorem allows us to express x and y (the coordinates of the unknown point) in terms of (xiy1), (x2y2), d1, and d2 da ( ) (y -), and d = (x-x2)2 + (y-y2 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 ty a where a=df-d-[(zf+y )-(Z3+3)] , and 2(y2 -v) Note that the two possible values for X, X4, 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 (x1, y1) and d2 from (x2-y2). "Tangulation refers to the fact that we need a third known point to decide which of (x+ y+) and (, .) is our sought-after point. So long as that third point (x3 ), is closer to (, y) than it is to (, 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 a3 np def a di, d2, xl, yl, x2, y2) numerator-dl* *2-d2**2-((x1* *2+yl*2) (x2* *2+y2*2)) denominator 2(y2-y1) return numerator/denominator def b xi, yl, x2, y2) return (x2-x1) (y2-yl) def solve xy xl, yl, x2, y2, di, d2): bb-b (x1, yl, x2,y2) aaFa (di, d2, xl,yl,x2,y2) pre 2 (x1-bb* (aa-yl)) den 2 (1+bb 2) xp (pretnp. sqrt (rad))/den xm-(pre-np. sqrt (rad))/den ym-aa return xm , ym, xp, yp Consider that point 1 is a distance of 4.1 (arbitrary units) from the unknown point with (x1,y1) coordinates of (-2.4,1.8) and that point 2 is a distance of 3.8 from the unknown point with (X2 y2) coordinates of 1.9-1.9). 1. Use the functions above to determine two potential sets of coordinates (xp yp) or (Xm 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 (xp. yp) or (Xm 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 (xp yp) and (K m) 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 (xp yp) and (Xm Ym followed by the coordinates of the reference point (x3 y3) and returns the coordinates of the point closest to the third point. The point closest to the reference point will be taken to be the unknown location. LAB ACTIVITY 10.25.1: LAB: Triangulation 0/30 main.py Load default template... 1 import numpy as np 2 def a d1, d2, x1, y1, x2, y2 3 numerator-di 2-d2*2-((x1*2-y12)-(x2* 2+y2 2)) denominator-2 (y2-y1) return numerator/denominator 4 7 def b x1, yl, x2, y2) return (x2-x1)/(y2-y1) 1e def solve xy( xi, yi, x2, y2, d1, d2 ): bb-b(x1,y1,x2,y2) aa a (d1,d2,x1,y1,x2,y2) 12 14 pre-2 (x1-bb (aa-y1)) 15 16 17 18 19 20 den-2 (1+bb**2) xp-(prenp.sqrt(rad))/den xm-(pre-np.sqrt(rad))/den 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 (x1y1) and (x2y2) Let (xy) be an unknown point whose distances to points 1 and 2 d1 and d2, respectively, are known. The Pythagorean theorem allows us to express x and y (the coordinates of the unknown point) in terms of (xiy1), (x2y2), d1, and d2 da ( ) (y -), and d = (x-x2)2 + (y-y2 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 ty a where a=df-d-[(zf+y )-(Z3+3)] , and 2(y2 -v) Note that the two possible values for X, X4, 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 (x1, y1) and d2 from (x2-y2). "Tangulation refers to the fact that we need a third known point to decide which of (x+ y+) and (, .) is our sought-after point. So long as that third point (x3 ), is closer to (, y) than it is to (, 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 a3 np def a di, d2, xl, yl, x2, y2) numerator-dl* *2-d2**2-((x1* *2+yl*2) (x2* *2+y2*2)) denominator 2(y2-y1) return numerator/denominator def b xi, yl, x2, y2) return (x2-x1) (y2-yl) def solve xy xl, yl, x2, y2, di, d2): bb-b (x1, yl, x2,y2) aaFa (di, d2, xl,yl,x2,y2) pre 2 (x1-bb* (aa-yl)) den 2 (1+bb 2) xp (pretnp. sqrt (rad))/den xm-(pre-np. sqrt (rad))/den ym-aa return xm , ym, xp, yp Consider that point 1 is a distance of 4.1 (arbitrary units) from the unknown point with (x1,y1) coordinates of (-2.4,1.8) and that point 2 is a distance of 3.8 from the unknown point with (X2 y2) coordinates of 1.9-1.9). 1. Use the functions above to determine two potential sets of coordinates (xp yp) or (Xm 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 (xp. yp) or (Xm 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 (xp yp) and (K m) 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 (xp yp) and (Xm Ym followed by the coordinates of the reference point (x3 y3) and returns the coordinates of the point closest to the third point. The point closest to the reference point will be taken to be the unknown location. LAB ACTIVITY 10.25.1: LAB: Triangulation 0/30 main.py Load default template... 1 import numpy as np 2 def a d1, d2, x1, y1, x2, y2 3 numerator-di 2-d2*2-((x1*2-y12)-(x2* 2+y2 2)) denominator-2 (y2-y1) return numerator/denominator 4 7 def b x1, yl, x2, y2) return (x2-x1)/(y2-y1) 1e def solve xy( xi, yi, x2, y2, d1, d2 ): bb-b(x1,y1,x2,y2) aa a (d1,d2,x1,y1,x2,y2) 12 14 pre-2 (x1-bb (aa-y1)) 15 16 17 18 19 20 den-2 (1+bb**2) xp-(prenp.sqrt(rad))/den xm-(pre-np.sqrt(rad))/den 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