3

This problem feel more complicated to me than usual. I am currently stuck with finding some values in the following case.

enter image description here

Here the image illustrate the basic of the problem. What the rules are :

  • A and B are always on the orange axis
  • AB,DE and CE are of known length
  • ABF, ADB and BEC are 90 degree
  • BF is infinite in that direction

What i need to find is what angle will make BF coincide with C ? By making BF falling down, A move up a bit while B goes toward the left so that make 2 unknowns that for some reason confuse me too much.

You can see the problem as ABF is a partial drawing of a book on angle in a shelf and the orange lines are the side and bottom of the shelf. The book as to touch the side and bottom and i need to know the angle it hold on the vertical toothpick CE

I am a developer so my current solution is to iterate increasing the length of AD and calculating the triangle of ADB and since ABF is also square i have the triangle BEF and F being infinite i get a point perfect inline with CE finally i can check if my F is higher than C if yes bring up A again a bit more and test until F is below C and get somewhere close to the real answer.

There must be a better way to calculate this.

Franck
  • 135
  • It is not quite clear what is fixed, what can be changed, and what quantity you are interested in finding. Can you formulate the problem a little more clearly? – Raad Shaikh Jan 11 '23 at 21:42
  • 2
    Hint: use similar triangles. – Sai Mehta Jan 11 '23 at 21:44
  • The problem, I suppose, confuses you because the confuguration you are looking for is not constructible and uses more variables. By constructible I mean everything could be calculated recursively, or inductively. Here you have defined the solution by lots of equations that hold in the final configuration, and not recursively. Use similar triangles as Sai suggested and translate your constraints as some equations involving solutions of polynomials. You should be able to make it one polynomial. The root of it would be the tanget of the angle you want. – donaastor Jan 11 '23 at 22:17

1 Answers1

5

You're correct that there's a better way. However, first note you could more simply, and I believe also easily, explain your goal by stating that with $AB$ being a fixed length, you're trying to determine the position of $B$ on $DE$ so that $AB$ and $BC$ are perpendicular to each other. Thus, this would be equivalent to $C$ and $F$ coinciding. The diagram below shows this, along with a few specified lengths and angles:

Diagram of OP with a few specified lengths and angles added

In particular, as you stated, $|AB| = a$, $|CE| = b$ and $|DE| = c$ are given. Also, set $|DB| = d$ (so $|BE| = c - d$) and $|AD| = e$ as unknown values.

With $\measuredangle ABD = x$ and $\measuredangle BAD = y$, we have $x + y = 90^{\circ}$. Thus, $\measuredangle CBE = 180^{\circ} - 90^{\circ} - x = 90^{\circ} - x = y$, so $\measuredangle BCE = x$. This means $\triangle ADB \sim \triangle BEC$, as indicated in Sai Mehta's comment.

Next, as suggested by donaastor's comment, using the relations among the similar triangles, plus the Pythagorean theorem, results in a system of several equations, which can be reduced to a polynomial in one of the unknown values. First, the Pythagorean theorem with $\triangle ADB$ gives that

$$d^2 + e^2 = a^2 \tag{1}\label{eq1A}$$

Next, using that $\triangle ADB \sim \triangle BEC$, we get

$$\frac{e}{d} = \frac{c-d}{b} \; \; \to \; \; \; e = \left(\frac{c-d}{b}\right)d \tag{2}\label{eq2A}$$

Substituting this into \eqref{eq1A} results in

$$\begin{equation}\begin{aligned} d^2 + \left(\left(\frac{c-d}{b}\right)d\right)^2 & = a^2 \\ (b^2)d^2 + (c-d)^2 d^2 & = a^2(b^2) \\ (b^2)d^2 + (c^2)d^2 - (2c)d^3 + d^4 & = a^2(b^2) \\ d^4 - (2c)d^3 + (b^2 + c^2)d^2 - a^2(b^2) & = 0 \end{aligned}\end{equation}\tag{3}\label{eq3A}$$

Since $a$, $b$ and $c$ are given, this is a quartic equation in the variable $d$. Although \eqref{eq3A} can be solved analytically, as shown in the Wikipedia article, it's usually solved numerically instead, e.g., such as by using the Durand–Kerner method that's also suggested in the article. However, I believe basically all programming languages have either built-in functionality or third-party libraries you can use instead to find the roots (e.g., in Python, there's numpy.roots).

Regardless of how you solve \eqref{eq3A}, with $d$ determined, then $y$ can be calculated in several ways, e.g., by

$$\sin(y) = \frac{d}{a} \; \; \; \to \; \; \; y = \arcsin\left(\frac{d}{a}\right) \tag{4}\label{eq4A}$$

However, especially if you try to solve this with your own code, be careful since quartic equations always have $4$ roots (due to the Fundamental theorem of algebra). I believe there'll usually be $2$ complex conjugates, with the other $2$ being real roots. You want the one with $0 \lt d \lt c$, with the other one being negative, i.e., with $B$ to the left of $D$ (and $A$ below $D$), as shown below:

Diagram showing how it could look with point B to the left of D on BE

From \eqref{eq2A}, we then also have that $e \lt 0$, as the diagram above indicates as well.

I assume you always want $B$ to be between $D$ and $E$. If so, especially if you're using your own root-finding method, you should try to ensure you get the correct root (e.g., by choosing an appropriate starting value) or, at the least, add appropriate checking and handling in case you get an out of bound root (i.e., $d \le 0$ or $d \ge c$) instead.

John Omielan
  • 47,976
  • I have been at trying to simplify the formula at point #3 for about 4 hours so far but no result yet. I'll still try to go at it for a little while then fall back to the trial and error iterative way as i know i can get a result. Not a good one but a close one and I'll have to do extra 2d collisions to adjust for the errors of the approximate. – Franck Jan 12 '23 at 14:22
  • 1
    @Franck Thank you for the feedback, but I'm not clear on a few things. By "point #3", I assume you mean my equation $(3)$. Also, if by "simplify" you mean solving it analytically, I recommend you don't try to do that, as it's fairly complicated and easy to make mistakes. Instead, you should try to solve it numerically, such as using a third-party library (my updated answer suggests numpy.roots if using Python). One last thing to note, as well, is that $\arcsin$ in many computer languages return angles in radians, so you may need to convert to degrees, in case that's the issue. – John Omielan Jan 12 '23 at 19:13
  • 1
    Yes i meant the formula at (3). I have finally managed to find a solution for d but it's long as hell and i double checked with Wolfram and it output 4 different solutions. I'll try finding a library in my langage that can solve equations for me to remove the chance of mistake in typing the formula. – Franck Jan 12 '23 at 19:55
  • After long hours of work neither mine or WolframAlpha solve for the formula for d = ? at (3) works. I'll have to fall back on iterative to get a close value and integrate the collision detection to adjust to a good enough value – Franck Jan 13 '23 at 16:35
  • @Franck I'm sorry you weren't able to get using $(3)$ working properly. However, I don't understand why. I've checked, and rechecked several times, my logic and algebra. After your initial comment, I also manually checked a simple case where $x = y = 45^{\circ}$, with $a = \sqrt{2}$, $b = d = 1$ and $c = 2$. I've just now checked a couple of additional cases. First, I generalized my earlier case with $a = \sqrt{2}d$ and $c = d + b$. Using this in the LHS of $(3)$ gives $d^4 - 2(d+b)d^3 + (b^2 + (d+b)^2)d^2 - 2b^2d^2$. Collecting the terms in the various powers of $d$ together gives for ... – John Omielan Jan 13 '23 at 21:21
  • @Franck (cont.) $d^4$ that $d^4 - 2d^4 + d^4 = 0$, for $d^3$ we get $-2bd^3 + 2bd^3 = 0$, and for $d^2$ the result is $2b^2d^2 - 2b^2d^2 = 0$. Thus, this matches the RHS of $0$. Second, I used $x = 60^{\circ}$ and $y = 30^{\circ}$, with $a = 2d$ then. For somewhat simpler algebra, I set $c - d = f$ (so $c = d + f$), which means $b = \frac{f}{\sqrt{3}}$. These values in the LHS of $(3)$ gives $d^4 - 2(d+f)d^3 + (\frac{f^2}{3} + (d+f)^2)d^2 - 2d^2\left(\frac{f^2}{3}\right)$. As before, collecting the powers of $d$ terms together gives for $d^4$ that $d^4 - 2d^4 + d^4 = 0$, ... – John Omielan Jan 13 '23 at 21:21
  • @Franck (cont.) for $d^3$ we get $-2fd^3 + 2fd^3 = 0$, and for $d^2$ the result is $\left(\frac{f^2}{3}+f^2\right)d^2 - \left(\frac{4f^2}{3}\right)d^2 = 0$. Thus, once again, the RHS of $0$ matches. Did you try inserting your values of $a$, $b$, $c$, and the value of $d$ which you got with your original iterative method, into the LHS $(3)$ to see whether or not you got a value close to $0$? If so, what sort of result(s) did you get? Also, if you don't mind and would like me to try to help further, please let me know at least one or two sets of values you got so I can check on them myself. – John Omielan Jan 13 '23 at 21:21
  • In programming you can't solve (3) to get d unless the formula is in the form of d = ??? i was not able to transform it and wolframAlpha tranformation did work but inputting a, b and c did not give the correct result so i assume either your formula or wolfram is wrong. I am currently implementing the iterative method and that take a while as i have many things to do at once. – Franck Jan 16 '23 at 11:50
  • @Franck Please provide example values of $a$, $b$ and $c$, as well as that of $d$ you believe is correct but which doesn't work in $(3)$. I'd like to investigate this further myself. Thank you, in advance, for your assistance. – John Omielan Jan 16 '23 at 19:15
  • a=0.75, b=4.5109. c=11.2102, d=0.287 – Franck Jan 16 '23 at 20:19
  • @Franck Using your values of $a$, $b$, $c$ and $d$, then $c-d=10.9232$. Using $x=\arccos\left(\frac{d}{a}\right)$, I got $x\approx 67.501^{\circ}$, and with $y=\arctan\left(\frac{b}{c-d}\right)$, I got $y\approx 22.439$. Thus, $x+y\approx 89.94$, which is close but a bit too small. Next, I got $2c\approx 22.4204$, $b^2+c^2\approx 146.0168$ and $a^{2}b^2\approx 11.44587$. Thus, the LHS of $(3)$ becomes approximately $r=d^4-22.4204d^3+146.0168d^2-11.44587$. Using your value of $d=0.287$, I got $r\approx 0.05815$, which is fairly small. I then tried a somewhat smaller value of $d=0.2865$ to ... – John Omielan Jan 16 '23 at 21:31
  • @Franck (cont.) get $x\approx 67.542^{\circ}$ and $y\approx 22.438^{\circ}$, so $x+y\approx 89.98^{\circ}$, with $r\approx 0.01900$. Thus, both $x+y$ and $r$ are improving. Next, I tried $d=0.2862$ to then get $x\approx 67.567$ and $y\approx 22.437$, so $x+y\approx 90.004^{\circ}$, with $r\approx -0.004456$. This shows $d$ is a bit too small. Note I did all of this manual work initially because Wolfram Alpha was down for a while with a proxy error. However, it's running now, with its result ... – John Omielan Jan 16 '23 at 21:31
  • @Franck (cont.) giving $d\approx -0.27420$, $d\approx 0.28626$, $d\approx 11.204-4.5046i$ and $d\approx 11.204+4.5046i$. Thus, this is as I suggested in my answer, i.e., the roots are a complex conjugate, a negative value and a positive value. With its positive value, I get $x\approx 67.562$ and $y\approx 22.438$, so $x+y\approx 90.000^{\circ}$, and $r\approx 0.00023$. Thus, overall, everything appears to work properly. Please check your work and results to see how they compare to mine. – John Omielan Jan 16 '23 at 21:32