Hi all,
I am working on a new arduino project, and i needed some help with the math. I've got the software skills to implement this function, but I am getting a little confused on the math. I drew a picture of what I am trying to do: http://s21.postimg.org/nyctfqr13/arduino_representation.png
essentially, there are servos at angles A and B
distance X is determined by a sensor
I am trying to create an arduino function that would be able to determine angle measurements based on the distance. "invisible" point C (the point not labeled by an angle) and point A are always at the same vertical height (8 cm).
Any help would be greatly appreciated. If you need more data, please ask.
TechnoD11
The angles of a triangle always add up to 180o.
(Before anyone argues about triangles on the surface of a sphere, I'm talking about planar triangles.)
Therefore, Angle C = 180o -Bo -Ao.
No need for anything more complicated than that.
I drew a diagram to label all points and all angles.
I used the Pythagorean Theorem to get all side lengths.
The bottom side is 16.612
I used the Law of Cosines to get angle B. (called A in the original diagram, sorry).
Would you like to see the equation for B, combining all laws and theorems?
AmbiLobe:
I used the Pythagorean Theorem to get all side lengths.
That would only be valid if you knew that this was a right angled triangle, which I don't think is the case here.
You can work this out using Pythagoras' theorem if you divide one of the sides to produce TWO right angled triangles and then solve those as simultaneous equations.
The original post describes an invisible point 8cm from something. I drew a new diagram calling the point d. There are 2 right angles at point d. I will draw a diagram, photograph it and show it to you.
Here is what the original description says, ""invisible" point C (the point not labeled by an angle) and point A are always at the same vertical height (8 cm). "
In other words, the bottom line is 8cm below point B (labeled Angle B) on the primitive diagram. I drew a vertical line from B to the bottom horozontal line and called that point d. Two right angles are at point d.
Hello and thanks all for the help so far. I have been looking through the various answers and doing a bit more searching on the internet and I created this code, which allows me to change the 'x' variable by increments of 1. the code is sort of rudimentary (and probably has a lot of unnecessary parenthesis), but the math looked sound to me. Here it is:
You might recognize the #include <math.h> at the top, that's a library I found from here:
acos() is arccos(), and the output is in radians (hence the conversion).
Anyway, after finally getting all this onto my arduino board (which is a nano v3.0 by the way), I got this in the serial monitor:
degangleC:0.00
degangleB:90.00
degangleC:0.00
degangleB:90.00
degangleC:0.00
degangleB:90.00
and so on...
changing the distance value with +/- didn't do anything
any help on math/software/etc would be helpful
thx again for all the help so far.
*edit
my apologies, I forgot to mention that I miscalculated a bit, the lengths of the two triangle sides are actually 14 cm and 10 cm, not 14.5 cm and 9.5 cm.
the output I am looking for is 2 angle measures, angles B and C (in my software and in picture below).
Your picture is a bit off, but that's not your fault, that's me giving a bad description. I took a little more time and created a more accurate picture which can be found here: http://s24.postimg.org/4jaojq41x/arduino_representation_2.png
Notes:
Point (angle) B is fixed, horizontally and vertically
Point (angle) A is fixed only vertically
What I am looking for is, without moving point B at all or point A vertically, what are the angle measures for angles B and C, given side length X (read from a sensor)
The triangle is not "fixed", its "fluid", in that the shape of the triangle will change based on the value of X.
The answer is the same as before. You know the length of all three sides of a triangle (14, 10, and X). You use the formulas I pointed to to calculate all the angles:
@Johnwasser
I already made the corrections when i put the code up a few posts back, that code has the values of 10 and 14, not the previous values. so the issue still stands.
TechnoD11: @Johnwasser
I already made the corrections when i put the code up a few posts back, that code has the values of 10 and 14, not the previous values. so the issue still stands.
In your code seems to be written assuming "^2" will square a number. Unfortunately for you the '^' operator is bitwise exclusive-OR, not 'raise to a power'. Try "distance*distance" in place of "distance^2", etc.