Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Misleadingly Simple Math Problem

Author
Message
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 05:50 Edited at: 14th Nov 2010 23:25
I spend a long time working on this problem. What I posted is a the problem simplified.

Here is the problem:


The Known:
1, 2, 3 = The Points (X1, Y1), (X2, Y2), (X3, Y3)
a, b, c, d, e, f = Lengths of sides

The Unknown:
(X, Y) - (Random Point)

Where a, b, c, and d, e, f are not equal.

Blue lines should be dashed. They are just distance from point 1,2,3 and (X, Y).

Should have made this clear: It is a scalene triangle.

I need to solve for (X, Y).

What I have tried:
Take Point 1 (X1, Y1) and Length d to it. I need to figure out how to break length d into x, y distances, but I can't seem to figure that out.

Any ideas?

Thanks,

DigitalFury
dark coder
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 14th Nov 2010 10:47 Edited at: 14th Nov 2010 11:01
(1+2+3)/3

Which is the basis of barycentric coordinates.

[edit] Unless you mean you don't wish to find the exact centre, but you wish to find the point based on the 3 lengths to the point, in which case it's much the same if you read up on the aforementioned! or this

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 18:21
@dark coder - It isn't the exact center. It would be to easy. A lot of google research did point me to: Barycentric coordinates but it was a bit to complicated for me to figure out. I have seen a few examples but couldn't figure out how to apply it to my problem.

Thanks

DigitalFury
Link102
21
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 14th Nov 2010 18:56 Edited at: 14th Nov 2010 18:57
this is just a guess, since I haven't looked into any of the barycentric coordinates stuff but;

(1*50% + 2*40% + 3*10%)/3

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 19:04 Edited at: 14th Nov 2010 19:06
@Link102 - That doesn't seem to be right because 50% in a number and the sides, angles, and points will always be changing.

I would assume you got the answer from this:



Just looking at it makes me confused. It has been a while since I have taken calculus.

I did pick up the part about a weighted sum. Link102 might be onto something, but the weights are all wrong. They should to be calculated.
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 14th Nov 2010 19:11 Edited at: 14th Nov 2010 19:12
Is there any more info to the problem? Like the 3 areas have to be the same? If so then read Dark Coder's post.

If not, and you just need a generally applicable solution for (x,y) given all your knowns, think about this:

Find the line that passes through (x,y) and is perpendicular to b. You can do this by considering a circle of radius f centred about 3, and e about 2. Do the same for a line perpendicular to c. Then you can see where these two lines cross and that's (x,y). It's made easier if there really is a right angle in your picture, but this isn't in the description.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 19:44
@Dr Tank - There isn't any right angles.

Just updated the information:

Quote: "Where a, b, c, and d, e, f are not equal.

Blue lines should be dashed. They are just distance from point 1,2,3 and (X, Y).

Should have made this clear: It is a scalene triangle."


Don't understand exactly what you are saying here. A picture would help a lot.
Quote: "You can do this by considering a circle of radius f centred about 3, and e about 2. Do the same for a line perpendicular to c."


Thanks,

DigitalFury
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 14th Nov 2010 20:08
Check out Dark Coder's link. Looks similar to my working. Here's another hint. http://en.wikipedia.org/wiki/Triangulation
Start by just considering the triangle with edges b,e,f.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 20:31 Edited at: 14th Nov 2010 20:36
@Dr Tank - According to a website I found about Triangulation:

Quote: "However, according to Skiena (1997), "this algorithm is quite hopeless to implement." "


Thought u might find that a bit funny. So now is it possible to implement?

Checked out Dark Coder's Link for Trilateration. It seems to apply to my problem. I just can't figure out radius of the circles. There is a lot more I still have to figure out.

Thanks,

DigitalFury
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 14th Nov 2010 21:14
Quote: " I just can't figure out radius of the circles."

d,e and f?
Teh Stone
16
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 14th Nov 2010 21:38
Are the blue lines meant to split the angle equally wher angle 123 is equal to 2x12(x,y)

I think I have it solved on paper if that's what you wanted if it is I'll type it up
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 22:05 Edited at: 14th Nov 2010 22:31
@Teh Stone - Blue lines = Dashed line. Just to represent the dist from point 1, 2, 3 and point (X, Y). You can't solve this from just using the angles because each angle is different.

@Dr Tank - Thanks. I will try to create an example in paint and ask a few more questions.

Here is what I have so far:


Method I am using: Trilateration

Still a bit hard to figure out from wikipedia.

Dark Coder:

Quote: "Find the line that passes through (x,y) and is perpendicular to b. You can do this by considering a circle of radius f centred about 3, and e about 2. Do the same for a line perpendicular to c. Then you can see where these two lines cross and that's (x,y). It's made easier if there really is a right angle in your picture, but this isn't in the description. "


Quote: "Find the line that passes through (x,y) and is perpendicular to b. You can do this by considering a circle of radius f centred about 3, and e about 2."


I think I might have positioned the circles incorrectly. I can't figure how to make a perpendicular line to b using the circle I added.

Feel free to mod the image. Would greatly help.

Thanks,

DigitalFury
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Nov 2010 22:31
If all the sides and the vertices are known then you only need vertices 1 and 3 and the lengths d and f in order to calculate (X,Y). You don't need length c because it can be deduced from the two vertices. The other information is totally irrelevant - except to tell you which of two possible solutions you need.

Just do the following:

1. Express d^2 and f^2 in terms of the coordinates of points 1, 3 and (X,Y).

2. Calculate the difference d^2 - f^2. This will enable you to express X in terms of Y (or vice versa) as a simple linear formula.

3. Express c^2 in terms of coordinates of points 1 and 3. This will give you a messy quadratic for X and Y.

4. In the equation from 3 just substitute X with the expression you found in 2 involving Y. The result will be a quadratic equation for Y.

5. Solve the quadratic for Y using standard methods. There will be two solutions.

6. Use the rest of the info to tell you which solution you want.

The laborious way of doing step 6 is to repeat the procedure for the other pairs of sides and see which vertex they all have in common.

No calculus, just algebra.

What's this thread doing on this board?
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 22:46
@Green Gandalf -

Quote: "What's this thread doing on this board?"


idk. No other place for it on any other board. It does have to do with vertexdata though...

Maybe I am just overcomplicating things/not understanding what you said..but:

Quote: "1. Express d^2 and f^2 in terms of the coordinates of points 1, 3 and (X,Y)."


I don't know how to express:
d*d and f*f

In Term of coordinates of points:
(X1, Y1), (X3, Y3), (X, Y)

d and f are distances that both can have an X, Y distance. If you are having me add them then how do you come up with the X, Y distance.

Quote: "2. Calculate the difference d^2 - f^2. This will enable you to express X in terms of Y (or vice versa) as a simple linear formula."


(X or Y) = (d * d) - (f * f) ` Right?

Could u clear it up a bit. Work better with drawing..and math isn't my forte.

Thanks,

DigitalFury
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Nov 2010 22:57
Quote: "and math isn't my forte"


Are you sure this exercise is for you?

The Geek culture board is the usual place for this sort of stuff.

Anyway, to answer your questions, if you have two vertices (X1,Y1) and (X2,Y2) then the square of the distance D between them is

D^2 = (X1-X2)^2 + (Y1-Y2)^2

You just need to apply that formula several times over plus a bit of algebra.
Teh Stone
16
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 14th Nov 2010 23:05
what i was asking is how do you define what (x,y) is

i was wondering if it is simply the point of intersection of the lines d,e,f and if the lines disect the angles

if that is what you want then it is simple
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Nov 2010 23:12
Quote: "and if the lines disect the angles"


I don't think they do necessarily.
Teh Stone
16
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 14th Nov 2010 23:14
i know we are tryin to calculate (x,y) but i dont actually no how he is placing (x,y)
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 23:24 Edited at: 14th Nov 2010 23:24
@Green Gandalf - Should actually be posted in the Newcomers DBPro Corner cuz I don't understand math...I took it...doesn't mean I understood it. :p lol

Make sure my math is right.



Then the same for:
(f * f) = (X1-X3)^2 + (Y1-Y3)^2

Forgot what I am trying to calculate...and this doesn't even seem right anyways...ahh..forgot x, y

Couldn't I just do this:



@Teh Stone - The point (X, Y) is a random point in the triangle.

Thanks,

DigitalFury
Teh Stone
16
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 14th Nov 2010 23:29
aw that clears it up thanks ermm sorry for wasting time thought i would be able to guessin you have just started AS/A level maths too
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Nov 2010 23:31
Quote: "Couldn't I just do this:"


No.

The square root of (a^2-b^2) is NOT (a-b). Just try it with a few numbers in place of a and b.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 14th Nov 2010 23:38 Edited at: 14th Nov 2010 23:43
@Green Gandalf - Oo yeah.

[d = sqrt((x1 - x2)^2 + (y1 - y2)^2)] = [d = sqrt((x1^2 - x2^2) + (y1^2 - y2^2))]

Can I legally work out: d^2 = (x1^2 - x^2) + (y1^2 - y^2) so that I get an x out of it? (then substitute to get y) and is this following what you posted above?

Thanks,

DigitalFury
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2010 00:59
Quote: "Can I legally work out: d^2 = (x1^2 - x^2) + (y1^2 - y^2) so that I get an x out of it?"


Yes, but it'll be a messy function of y. Use the step 2 I suggested before - when you expand the squared bracketed x and y terms and calculate the difference, you'll see several things cancel out.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 15th Nov 2010 01:22
@Green Gandalf - Thanks for you help. I'll get to working out the formulas later tonight.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 15th Nov 2010 01:45 Edited at: 15th Nov 2010 02:04
ok, just thinking outloud here. If all you want to do is figure out the x/y coordinate of the "random point", since you pretty much know everything else, you can swing an arc, or circle around each point 1,2,3, with a radius of d,e,f. You can easily calculate the coordinate at each point on the circle using simple trig functions.(sine, cos) Compare the coordinates. List maybe? There will only be one point where all three circles intersect within the triangle, or, share the same coordinate, your "random point". In fact, I bet you could do this just checking 2 points, because you can also easily calculate the internal angles of the triangles. I guess this might not be the fastest way to do it, but, its easily understood, to me anyway. BTW, this is a common technique done in sheetmetal fabrication using a compass to find true lengths of lines.

EDIT:
doh, even easier than that. He KNOWS ALL THE SIDES!
SSS
Pythagorus.
http://www.teacherschoice.com.au/Maths_Library/Trigonometry/solve_trig_SSS.htm

EDIT again
I got bored along time ago and wrote some code to solve triangles. I'll see if I can find it.

EDIT AGAIN, sorry
also, since according to the drawing, even angles are a given, then its just a simple vector trig problem. Only need one point. I just don't understand how all three internal lines can be known. There will be situations where the lines never intersect, because lengths are too short.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 15th Nov 2010 02:16
@Visigoth - I think it is called: Trilateration. That was the first method suggested. Green Gandalf suggested re-writing the distance formula. Either way let me know. Code would be awesome. Thanks.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 15th Nov 2010 02:37 Edited at: 15th Nov 2010 04:24
@Digital Fury
With the information you supplied, all you need to do is run a sine() and cosine() function using the internal angle of the scalene triangle on ANY point and multiply by the radius then add to the graph origin to get the x,y coordinate you are looking for. IF you are wanting to input different length values, it is possible to have no intersection in points. So, what is the real problem here? With the GIVENS you supplied, is intersection guaranteed at the end of the length?

EDIT:
and, btw, in sheetmetal work, we use Triangulation. We use fixed lengths set to a compass, and scribe an arc from a point. Where any two lines intersect, this is another point. From there, points can be measured. Sometimes, we don't know the third point, and only work off distances. Angles are rarely used, as true lengths can be determined from third dimensions. This problem sounds more like triangulation, to me, anyway.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 15th Nov 2010 02:43 Edited at: 15th Nov 2010 02:43
@Visigoth - Math lingo. ahh. na jk I could figure it out after drawing it out. I will work on the prob later.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 15th Nov 2010 02:47
ya, ok. Just wondering if this was a quiz or something.
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 15th Nov 2010 15:00 Edited at: 15th Nov 2010 15:03
Not sure if this is any use as my trig sucks, but it works fine as long as y1>y4 (point 1 is further down the screen) otherwise the calculated y values of point 4 come out odd, if someone could point out where I've gone wrong I'd appreciate it.

Here's the code I've got:


I think the problem with this is in the way I get the beta angle. I hope this helps get a little closer to the answer.

Thanks,
Broken_Code

[EDIT]
I should probably point out that point 4 is the unknown point we're trying to find.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 15th Nov 2010 20:58 Edited at: 15th Nov 2010 21:01
@Broken_Code - Will definately check that out. Green Gandalf might be able to help you better then I could though.

@Green Gandalf - Here is my work so far. Confused with a few things:

Quote: "1. Express d^2 and f^2 in terms of the coordinates of points 1, 3 and (X,Y)."




Quote: "2. Calculate the difference d^2 - f^2. This will enable you to express X in terms of Y (or vice versa) as a simple linear formula."




Quote: "3. Express c^2 in terms of coordinates of points 1 and 3. This will give you a messy quadratic for X and Y."


Question: Do I leave it in this form?:


Quote: "4. In the equation from 3 just substitute X with the expression you found in 2 involving Y. The result will be a quadratic equation for Y."




Quote: ""substitute X""

Where is X? You said in terms of points 1 and 3. There is only x1 and x3.

Use this:
to solve for x1, x3, y1, y3 then plugin???

I want Y = something, but there is no Y in the equation..unless you are talking about y1 and y3.

Thanks,

DigitalFury
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2010 21:29
Quote: "@Green Gandalf - Here is my work so far. Confused with a few things:"


Sorry. I misread one of your earlier posts.

You asked:

Quote: "Can I legally work out: d^2 = (x1^2 - x^2) + (y1^2 - y^2) so that I get an x out of it? (then substitute to get y) and is this following what you posted above?"


And I answered "yes". I didn't notice that you'd moved the squares inside the brackets which is NOT legitimate.

As I mentioned earlier,



It is NOT true in general that (a - b)^2 = (a^2 - b^2). Just try it with the numbers such as a=5, b=3, etc. You should already know that



and just apply it to your X's and Y's.

You really need to grasp these basic facts of algebra and arithmetic before trying to solve a problem like this.

Quote: "Where is X? You said in terms of points 1 and 3. There is only x1 and x3."


You'll find that question is answered when you get the above point right.

Sorry about my earlier oversight.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 15th Nov 2010 21:33
@Green Gandalf - Oops. Read what you said backwards. I'll rework all of it. lol
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2010 21:43
Quote: "I'll rework all of it."


Maths is like that - even when you think you know what you're doing. One small slip early on and the whole edifice comes crashing down.

A bit like coding really.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 15th Nov 2010 22:00
@Green Gandalf - Yep...soo true. One has to wonder if it is really worth fixing more hrs of mistakes then it takes to actually code it all. lolz
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 16th Nov 2010 09:36 Edited at: 16th Nov 2010 10:16
here is a 2D interactive program that demonstrates how to solve this problem using the SSS solution.
5% of this code, tops, is the 2 functions to solve the triangle and plot the coordinates. The other 95% is displaying it all.

no media or anything, all 2d.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Nov 2010 11:33
You need to understand trig to understand that method of course - but if you do then it's the neater way of course.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 16th Nov 2010 20:25
@Visigoth - I'll take a look at it when I have time. Thanks. I'll have to see if it works. I am still going to work out the math for the other method. I would bet the trig version is faster. We'll see which one is faster though.

DigitalFury
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 17th Nov 2010 22:35
@Green Gandalf -

Quote: "3. Express c^2 in terms of coordinates of points 1 and 3. This will give you a messy quadratic for X and Y."


c^2 = (x1 - x3)^2 + (y1 - y3)^2

Quote: "This will give you a messy quadratic for X and Y"
How so? Don't I just do the same thing I did for step 1?

Thanks,

DigitalFury
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2010 23:33
Quote: "3. Express c^2 in terms of coordinates of points 1 and 3. This will give you a messy quadratic for X and Y."


Don't know why I said that.

Replace that with:

3. Express d^2 + f^2 in terms of the same coordinates as in step 1. This will give you a messy quadratic for X and Y.

I seem to be having a few off moments.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 18th Nov 2010 01:49 Edited at: 18th Nov 2010 01:55
@Green Gandalf -

Quote: "2. Calculate the difference d^2 - f^2. This will enable you to express X in terms of Y (or vice versa) as a simple linear formula."


Are you sure:
Quote: "d^2 - f^2"
is not d^2 + f^2.

Quote: "3. Express d^2 + f^2 in terms of the same coordinates as in step 1. This will give you a messy quadratic for X and Y."


Like This?: [(x1 - x)^2 + (y1 - y)^2] + [(x3 - x)^2 + (y3 - y)^2]
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 18th Nov 2010 01:51 Edited at: 18th Nov 2010 01:59
@Green Gandalf - Here's all the math:


Re-Working Math:

Quote: "1. Express d^2 and f^2 in terms of the coordinates of points 1, 3 and (X,Y)."


Original:


For dx:


For dy:


For fx:


For fy:


Quote: "2. Calculate the difference d^2 - f^2. This will enable you to express X in terms of Y (or vice versa) as a simple linear formula."




rewrite using this rule:
Quote: "(a - b)^2 = a^2 - 2*a*b + b^2"




3. Express d^2 + f^2 in terms of the same coordinates as in step 1. This will give you a messy quadratic for X and Y.

This good?:


Make sure I done everything correctly.

Thanks,

DigitalFury
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 02:14
Quote: "Are you sure:
Quote: "d^2 - f^2"
is not d^2 + f^2."


Yes, quite sure.

Quote: "Quote: "3. Express d^2 + f^2 in terms of the same coordinates as in step 1. This will give you a messy quadratic for X and Y."

Like This?: [(x1 - x)^2 + (y1 - y)^2] + [(x3 - x)^2 + (y3 - y)^2]"


Yes - but don't forget the other side of the equation which is the known constant d^2 + f^2.

Quote: "Re-Working Math:
1. Express d^2 and f^2 in terms of the coordinates of points 1, 3 and (X,Y).
Original:
d^2 = (x1 - x)^2 + (y1 - y)^2
f^2 = (x3 - x)^2 + (y3 - y)^2
"


Yes.

Quote: "For dx:
- (x1 - x)^2 = (y1 - y)^2 - d^2
(x1 - x)^2 = -(y1 - y)^2 + d^2
Sqrt[(x1 - x)^2] = Sqrt[-(y1 - y)^2] + Sqrt[d^2]
(x1 - x) = -(y1 - y) + d
- x = -(y1 - y) + d - x1
x = (y1 - y) - d + x1
For dy:
-(y1 - y)^2 = (x1 - x)^2 - d^2
(y1 - y)^2 = -(x1 - x)^2 + d^2
Sqrt[(y1 - y)^2] = Sqrt[-(x1 - x)^2] + Sqrt[d^2]
(y1 - y) = -(x1 - x) + d
- y = -(x1 - x) + d - y1
y = (x1 - x) - d + y1
"


No, for at least two reasons:

1. you should be calculating the difference d^2 - f^2 as in your step 2 (which means that the x^2 and y^2 terms cancel out if you do it right - then you get your linear equation in x and y)
2. the sqrt of a^2 + b^2 is NOT a + b (except in special cases) - just as the square of a + b is NOT a^2 + b^2 in general.

Quote: "2. Calculate the difference d^2 - f^2. This will enable you to express X in terms of Y (or vice versa) as a simple linear formula.
` Hmm anything I can do with this?:
Dist = [(x1 - x)^2 + (y1 - y)^2] - [(x3 - x)^2 + (y3 - y)^2]
rewrite using this rule: (a - b)^2 = a^2 - 2*a*b + b^2
Dist = [(x1^2 - 2*x1*x + x^2) + (y1^2 - 2*y1*y + y^2)] - [(x3^2 - 2*x3*x + x^2) + (y3^2 - 2*y3*y + y^2)]"


Yes, this is what you should be working with - that's where the x^2 and y^2 terms cancel out if you're careful with removing brackets. Then use your step 3 which I commented on earlier in this post.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 02:23
Er, you edited your post while I was replying to it. Confusing. With luck, what I've said will make sense anyway.

Some quick comments for now:

-Don't forget the other side of your equations.
-You don't need the things you've called dx, df, etc. I'm not sure what they're meant to be.
-What do you mean by "dist" in the line

Quote: "Dist = [(x1 - x)^2 + (y1 - y)^2] - [(x3 - x)^2 + (y3 - y)^2]"


? It should be the difference between d^2 and f^2, i.e.



You know the LHS of that equation but the RHS involves the two unknowns x and y.

I think you're getting there.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 18th Nov 2010 02:39 Edited at: 18th Nov 2010 02:48
@Green Gandalf - Slowly. I'll figure it out eventually. Lots more to look over and lots more work. Will get to it when I can.

Few things fixed/working on:

#1:

Quote: "2. the sqrt of a^2 + b^2 is NOT a + b (except in special cases) - just as the square of a + b is NOT a^2 + b^2 in general"


Where exactly did I go wrong in #1?

Quote: "-You don't need the things you've called dx, df, etc. I'm not sure what they're meant to be."


Why Not? How should it be written? I was just solving for x and y because I thought that has to be done so you end up with an x, y answer. I realized that you didn't ask for an x, y answer so how it is suppose to be written?

For dx:



#2:


#3:


Thanks,

DigitalFury
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 18th Nov 2010 06:59
I don't understand why you are beating yourself up over this.
The solution IS simple, you obviously haven't looked at my example.
The only trig you need to know is how to use the sin() and cos() function, thats it! If you can't grasp those two functions, well, you'll need to, because its the core of graphing anything.

2 steps, solve any ONE internal triangle to get the angles then plot the coordinates.

the 2 functions to do this, stripped down without extra comments



I posted in my previous post the source of the formula for solving a triangle when 3 sides are known.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 18th Nov 2010 09:42
@Visigoth - Sorry I haven't yet. I am just so determined to solve Green Gandalf's version. lol I also want to see if Green Gandalf's version is any faster.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 11:56 Edited at: 18th Nov 2010 11:58
Quote: "#1:


Quote: "2. the sqrt of a^2 + b^2 is NOT a + b (except in special cases) - just as the square of a + b is NOT a^2 + b^2 in general"

Where exactly did I go wrong in #1?"


Here:



The square root of "-(y1 - y)^2 + d^2" is not "Sqrt[-(y1 - y)^2] + Sqrt[d^2]" for two reasons:

1. the square root operation is not distributive, i.e. sqrt(a+b) is not equal to sqrt(a)+sqrt(b) in general
2. it doesn't make sense here to take the square root of a negative number.

Just put some numbers in to see what happens with your formula.

Nothing wrong with the following except you haven't tried to cancel out terms in #2 - just multiply out the brackets.

Quote: "#2:
+ Code Snippet
d^2 - f^2 = [(x1 - x)^2 + (y1 - y)^2] - [(x3 - x)^2 + (y3 - y)^2]

#3:
+ Code Snippet
d^2 + f^2 = [(x1 - x)^2 + (y1 - y)^2] + [(x3 - x)^2 + (y3 - y)^2]
"


For example, in #2 expand the first square as follows:



Do the same with the other terms, then you should see some terms cancel out when you put it all together (if you're careful with minus signs).

@Visigoth

This problem can be solved by elementary algebra, i.e. without trig - let DigitalFury master that first.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 18th Nov 2010 20:26
@GG
well, he didn't seem to have any problems with using trig functions when he posted this:

http://forum.thegamecreators.com/?m=forum_view&t=175605&b=6

just sayin'
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2010 20:34
Hmm?

Login to post a reply

Server time is: 2026-07-21 18:58:15
Your offset time is: 2026-07-21 18:58:15