Dynamically finding distances and angles between user-specified points
- To: mathgroup at smc.vnet.net
- Subject: [mg125130] Dynamically finding distances and angles between user-specified points
- From: Andrew DeYoung <adeyoung at andrew.cmu.edu>
- Date: Thu, 23 Feb 2012 05:46:44 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hi, I wish to create a simple Manipulate-type interactive "applet" in which the user can control the (x,y) coordinates of two points, which I will call points B and E. (Suppose that B has coordinates (xB,yB) and E has coordinates (xE,yE).) Now suppose there are points A, C, D, and F which are fixed in space. A and B, B and C, B and E, D and E, and E and F are connected by line segments. I would like to write a Manipulate-type dynamic "applet" that prints the values of various line segments (for example, of line segments AB and BE) and of various angles (for example, of angles ABC, DEF, and ABE), preferably updated dynamically. I have posted a figure showing these points and their relation to one another: http://www.andrew.cmu.edu/user/adeyoung/feb22/figure.gif I made the above posted figure with the following commands: (* Begin code *) r = 0.03; a = 1; b = 1; p1 = {a, b}; p2 = {-a, b}; p3 = {-a, -b}; p4 = {a, -b}; p5 = {0, 0.5}; p6 = {0, -0.5}; Show[{ Graphics[{Red, Table[Disk[i, r], {i, {p1, p2, p3, p4}}]}, Axes -> True, AxesLabel -> {"x", "y"}, AspectRatio -> 1], Graphics[{Black, Table[Disk[i, r], {i, {p5, p6}}]}], Graphics[{ Text[Style["(xB, yB)", 18], p5, {-1.2, 0}], Text[Style["(xE, yE)", 18], p6, {-1.2, 0}], Text[Style["A", Red, 18], p1, {-1.8, 0}], Text[Style["C", Red, 18], p2, {1.8, 0}], Text[Style["F", Red, 18], p3, {1.8, 0}], Text[Style["D", Red, 18], p4, {-1.8, 0}], Text[Style["B", 18], p5, {-1, -1}], Text[Style["E", 18], p6, {-1, 1.5}], Line[{p1, p5, p2}], Line[{p3, p6, p4}], {Thickness[0.01], Line[{p5, p6}]}, Text[Style["\[Angle]ABC = ?", 14], {0.6, 0.6}, {-1, 0}], Text[Style["\[Angle]DEF = ?", 14], {0.6, 0.5}, {-1, 0}], Text[Style["\[Angle]ABE = ?", 14], {0.6, 0.4}, {-1, 0}], Text[Style["AB = ?", 14], {0.6, 0.3}, {-1, 0}], Text[Style["BE = ?", 14], {0.6, 0.2}, {-1, 0}] }] }] (* End code *) My question is, do you have any advice for computing the distances and angles dynamically? Do you recommend that I use a Locator or a Slider2D control object? Also, do you think that I can compute the angles dynamically using the following vector relation? pvector (dot product) qvector = Norm[pvector]*Norm[qvector]*Cos[\ [Theta]] where \[Theta] is the angle between pvector and qvector. So \[Theta] is: \[Theta] = ArcCos[Dot[pvector, qvector]/(Norm[pvector]*Norm[qvector])] If, for example, I want to find the angle ABC, then pvector is the vector from A to B (or from B to A) and qvector is the vector from B to C (or from C to B). Thanks so much for your time. Andrew DeYoung Carnegie Mellon University