FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MATHEMATICS

Find the coordinates of the top of a triangle


I have to work out some XY coordinates of points which are extracted from surveying type data. I have a lot of trig stuff already but there must be an easier way to do this one.

There is a base line, with points A and B at ends of the line. The distance between A and the point C and B and the point C are given. So what are the X,Y's of the point C?
                           C
                    /            \
               /                      \
          /                               \
     A---------------------------------------- B
I can work this out by going back the the high school revision maths books I have had to buy but it hurts my broin.
JC

You can avoid Trig altogether if you want to do the following:

1. Calculate the area of the triangle defined by the lines a,b and c (connecting Pts. A,B,C) using:

A = sq root of [s(s-a)(s-b)(s-c)] where s = (a + b + c)/2 (Known asHeron's Formula)

2. Multiply the Area by 2 and divide by the length of side c

3. This gives you the Altitude CD, which would correspond to the Y coordinate of pt C from the base line AB. Using this length you can then calculate length AD and DB using Pythagoras' Theorem.

Maybe Trig would be easier.

Joe Wilkins

Here's the answer that I get:

Let "A" be the origin of the coordinate system, so that x is measured as a distance to the right of "A". Then we have:
    x = (AC^2 - BC^2 + AB^2) / 2AB
and:
    y = SQR(AC^2 - x^
Rick

I can't figure out what distances you know.

Assuming you know the lengths AC, AB and BC, use law of cosines to find angle A. BC^2 = AC^2 + AB^2 - 2cos A. Solve for A in the cos A. Now the coordinates for point C will be: (AC*cos A, AC*sin A)

Jim Mumaugh

I was wading through the ideas I got back on the surveying stuff...

Its a method used to measure the shapes of things like swimming pools etc. You draw a base line AB, and measure the outline at a series of points around it from the ends of your base line... Therefore you always know AC and BC.

Jim Mumaugh wrote....

Assuming you know the lengths AC, AB and BC, use law of cosines to find angle A. BC^2 = AC^2 + AB^2 - 2cos A. Solve for A in the cos A. Now the coordinates for point C will be: (AC*cos A, AC*sin A)

That was a help, but the problem was that knowing CosA is fine, but getting that back to the actual angle of A is another. Pressing ACOS on a calculator will get you the answer, but there is no direct ACOS function in FB, and the function is really complicate and not really human readable. (Lot of broin hurts at this stage)

Then I realised that you don't actually need to convert CosA back to an angle if all you need is the X and Y's and really the whole thing is straigt maths.
CLEAR LOCAL
LOCAL FN Len2Coord$(AB$,AC$,BC$)
  AB# = VAL(AB$) :  AC# = VAL(AC$) : BC# = VAL(BC$)
  Top#  = (AB# ^2 + AC# ^2 - BC# ^2)
  Botm# = (2 * AB# * AC#)
  CosA# = Top#/Botm#
  X# = CosA# * AC#
  Y# = SQR(AC# ^2 - X# ^2)
  Out$ = STR$(X#) + "," + STR$(Y#)
END FN = Out$
JC