Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python 10.25 LAB: Triangulation Triangulation is the process of locating an unknown point given two known points and distances from those known points Consider

image text in transcribedimage text in transcribedimage text in transcribedIn Python

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 (xy) and (x22) 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 (xy). (x2y2), di, and d2 d_ (z-z1 )2 + (y-in), and 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: 2)12and = 2(1 + b2) 2(32-) x2-x1 Note that the two possible values for x, x+, 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,(xy) and (x, y ), that are each d1 from (x1, y1) and d2 from (X2 Y2). Triangulation" refers to the fact that we need a third known point to decide which of (x %) and (x, y) is our sought-after point. So long as that third point (Kg ), is closer to (x %) than it is to (x, 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 d1, d2, xl, yl, x2, y2) numerator-di* 2-d2* *2(x1**2+y1**2)x22ty2**2)) denominator-2* (y2-yl) return numerator/denominator def b( xl, yl, x2, y2): return -(x2-xl)/ (y2-yl) def solve_xy( xl, yl, x2, y2, dl, d2) bb-b (xl,yl, x2,y2) aa-a (di,d2,x1,yl, x2,y2) rad-4* (bb* (aa-yl)-x1)**2-4* (1+bb**2) * (x1* *2-di**2+ (yl-aa) **2) pre-2* (x1-bb (aa-yl)) 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 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) Consider that point 1 is a distance of 4.1 (arbitrary units) from the unknown point with (x.y) 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 (-19,-19). 1. Use the functions above to determine two potential sets of coordinates (xo y0) or (m yr) 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 givern distance can be calculated using the original known coordinates and the (, yp) or (myn) coordinates 2. Define a function called pythagoras that takes as arguments the coordinates of two points (eg, for a and b, (xa, ya, xb. ) and returns the distance between the two points. 3. Use pythagoras to determine if the calculated distances of point 1 from (p yp) and (Xm 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 (p Yp) and ( followed by the coordinates of the reference point (x3 y3) and returns the coordinates of the point closest to the third point ym The point closest to the reference point will be taken to be the unknown location ACTY 0.25.1: LAB: Triangulation 0/30 main.py Load default template.. 1 import numpy as np 2 def a d1, d2, x1, yl, x2, y2 ): 3 numerator-d1* *2-d2**2 ((x1 *2+y1**2)-(x2* *2+y2**2)) 4 denominator-2 (y2-yl) return numerator/denominator 6 7 def b x1, yl, x2, y2 ): 8 return -(x2-x1)/(y2-y1) 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 (xy) and (x22) 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 (xy). (x2y2), di, and d2 d_ (z-z1 )2 + (y-in), and 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: 2)12and = 2(1 + b2) 2(32-) x2-x1 Note that the two possible values for x, x+, 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,(xy) and (x, y ), that are each d1 from (x1, y1) and d2 from (X2 Y2). Triangulation" refers to the fact that we need a third known point to decide which of (x %) and (x, y) is our sought-after point. So long as that third point (Kg ), is closer to (x %) than it is to (x, 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 d1, d2, xl, yl, x2, y2) numerator-di* 2-d2* *2(x1**2+y1**2)x22ty2**2)) denominator-2* (y2-yl) return numerator/denominator def b( xl, yl, x2, y2): return -(x2-xl)/ (y2-yl) def solve_xy( xl, yl, x2, y2, dl, d2) bb-b (xl,yl, x2,y2) aa-a (di,d2,x1,yl, x2,y2) rad-4* (bb* (aa-yl)-x1)**2-4* (1+bb**2) * (x1* *2-di**2+ (yl-aa) **2) pre-2* (x1-bb (aa-yl)) 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 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) Consider that point 1 is a distance of 4.1 (arbitrary units) from the unknown point with (x.y) 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 (-19,-19). 1. Use the functions above to determine two potential sets of coordinates (xo y0) or (m yr) 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 givern distance can be calculated using the original known coordinates and the (, yp) or (myn) coordinates 2. Define a function called pythagoras that takes as arguments the coordinates of two points (eg, for a and b, (xa, ya, xb. ) and returns the distance between the two points. 3. Use pythagoras to determine if the calculated distances of point 1 from (p yp) and (Xm 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 (p Yp) and ( followed by the coordinates of the reference point (x3 y3) and returns the coordinates of the point closest to the third point ym The point closest to the reference point will be taken to be the unknown location ACTY 0.25.1: LAB: Triangulation 0/30 main.py Load default template.. 1 import numpy as np 2 def a d1, d2, x1, yl, x2, y2 ): 3 numerator-d1* *2-d2**2 ((x1 *2+y1**2)-(x2* *2+y2**2)) 4 denominator-2 (y2-yl) return numerator/denominator 6 7 def b x1, yl, x2, y2 ): 8 return -(x2-x1)/(y2-y1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions