123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|684|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> triangle maths problemI

Sun, 13 Dec 2009, 10:40
JL235
I am currently implementing a mock robot scenario, but I need to do some maths and I'm a little stumped. Here is my problem.

I have a point, X, and I want to know how far away I am from it. However I can only get it's angle. So I am thinking I will move forward 100 places and then get the angle a second time. Using this surely I must be able to get it's distance from the original point, right?


Essentially I know the two theta's, and I know the length of the side on the right (100). I want to find out the length of D.

How can I do this?
Sun, 13 Dec 2009, 11:00
Jayenkai
At work, usually good for thinking time, so if no-one else has it done, I'll see what I can come up with.

-=-=-
''Load, Next List!''
Sun, 13 Dec 2009, 11:21
Jayenkai
Completely untested, pure "Jay's random headstuff", so will more than likely be wrong..

100/ASin(Ang1-Ang2) = answer?

try ang2-ang1, try acos, try allsorts!!!

-=-=-
''Load, Next List!''
Sun, 13 Dec 2009, 11:37
HoboBen
Find the other two inside angles of the triangle:

for top right 180 - angle
for top left angles in triangle sum to 180



Then

B/sin(b) = 100/sin(a)

B = 100 * sin(b) / sin(a)




-=-=-
blog | work | code | more code
Sun, 13 Dec 2009, 16:55
Scherererer


Should work.

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Mon, 14 Dec 2009, 08:19
shroom_monk
Get the inside angles of the triangle, then use the sine rule.

|edit| Wait, that's basically what HoboBen suggested... |edit|

-=-=-
A mushroom a day keeps the doctor away...

Keep It Simple, Shroom!
Mon, 14 Dec 2009, 08:58
JL235
Thanks, pretty certain this bit is sorted. But I'm still stuck on the larger problem as a whole.

This diagram is the entire algorithm I've devised quickly drawn out in Paint.NET:


I start at the upper pink spot and need to get to the mid-point between V and G. I am never told the distance to G and V. But I can turn and then search for them in my field of view. I know how much I've turned and my bearing to G and V.

The pointed arrows are states where the robot has turned to look in that direction. The t0, t1, t2 and t3 are given values, these are the turns I am performing (in that order) in order to search for G and V. g1, g2, v1 and v2 are also given, these are the bearings from the current view to G and V.

To work out the distance to G and V I move 400 places after t1 and then spin and search a second time. By seeing how much their bearing has changed between my first location and the new one I can work out where they are. From this I can work out their midpoint and hopefully move there.

After t3 I need to then turn 'tr' and travel 'D'. These are the two values I need to work out.

I've tried implementing the maths behind it, but D ends up being a very large number and the tr value I get just seems to be random. So I'm not sure if my maths is right or not.

If someone could help go through the maths for working this out, I'm sure I could work out how to implement it and solve the problem.

|edit| Two points, first after turn t1 and t3 the robot is pointing in the same direction. In this example that is pure coincidence.

Second, after both t0 and t2 the robot is pointing in the same direction. Again this is just coincidence. |edit|

Mon, 14 Dec 2009, 13:19
shroom_monk
Have you tried modelling it in something like Geogebra? That might be easier to visualise.

I'll give it a shot.

|edit| I'm slightly lost with your diagram. Could you list which values you know, or do you know all of them? |edit|

-=-=-
A mushroom a day keeps the doctor away...

Keep It Simple, Shroom!
Mon, 14 Dec 2009, 18:06
JL235
All of them, except tr and D. Those are the values I am trying to work out.

However I think this is now solved. After sitting for a few hours and explaining it all to a CS friend of mine I found loads of bugs with my workings. I'm getting ok results now where the robot finds the mid-point in the middle to an acceptable degree of accuracy.

Would people be interested in me drawing up and posting my solution?
Tue, 15 Dec 2009, 13:54
shroom_monk
Yeah, I'd be interested to see it.