Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with some trig

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
I haven't taken trigonometry yet so I know little about it. Heres the problem: I have a line with known endpoints (x,y) and (x2,y2) which crosses another point (x3, unknown).
Can somebody give me the formula to get the unknown
ps. I will also need the formula to get (unknown, y3)
pps. I tired y = mx+b and the pythagorean theoren they don't work
 
There's not enough info in your question to give an answer.

Are x2,y2 the points of a second line? If so, how do the lines cross at x3? At right angles? Or at what angle do they cross? What or where is y3?

What is the unknown that you want the formula for?
 
(x,y) and (x2,y2) are the endpoints of the first line.
(x3, unknown) is the point where the first line touches another, vertical line (this was the part i forgot to put in).
The angle will be different everytime.
 
Probably the best thing to do is to search of the web for maths sites. I use either Dogpile at or AllTheWeb at
In either one of these type in "equation of a straight line"
and you'll get at least a dozen sites showing these equations.

Both Dogpile and Alltheweb are meta engines and use about a dozen search engines for their results.

Ray
 
Perhaps I am missing something. If x,y and x2,y2 are co-ordinates of the line ends, then it is a straight line of defined length and angle to the verticle. How can that change?
 
pebe:
The angle will be different because all of the variables will be different each time I run it.

(| invisible area)
(v )
\ |
\ |
\|
* (visable area)
| \
____|
It is for a GUI. If the scripting language calls for a line on a window that is behind another window, I need to know where to start it (the asterisk in the graphic above) The part behind the box is not visible
 
y3=y1+(y2-y1)/(x2-x1)*(x3-x1)
Not tested and not guaranteed but the intent is to get the slope , using that to figure how much the y variable should be on the slope and calculate the position based on the initial y1. Ed Fair
unixstuff@juno.com
Any advice I give is my best judgement based on my interpretation of the facts you supply. Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.
 
Thanx edfair! Looks like I didn't need trig after all!
 
Trigonometry is for use when you need to calculate angles or derive information from angles. This is simply intersection. Here is a simple derivation of edfair's expression:

There are a number of standard forms for expressing lines. I will start with the following:

(y - y1) = m(x - x1)

Intuitively, this can be seen as translating the line to put (x1, y1) at the origin, and then constructing a line of the form y = mx + b where b is zero since the line passes through the origin.

The value m here is the slope of the line. We know this to be the rise over the run. In this case, we know the rise to be (y2 - y1) and the run to be (x2 - x1). This leaves us with the following expression, with x and y as unknowns:

(y - y1) = ((y2 - y1) / (x2 - x1))(x - x1)

Since this equation must hold for all points (x, y) along the line, it must therefore also hold for (x3, unknown). I will use y3 to denote unknown. Inserting x3 and y3 into the equation for the line, we get:

(y3 - y1) = ((y2 - y1) / (x2 - x1))(x3 - x1)

Solving for y3, we get:

y3 = y1 + ((y2 - y1) / (x2 - x1))(x3 - x1)

..which is the equation given by edfair.
 
Just so you know, there is trig involved here, just not named.
Slope as described here is the trig function tangent. Ed Fair
unixstuff@juno.com
Any advice I give is my best judgement based on my interpretation of the facts you supply. Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.
 
Of course, the very word "trigonometry" means "measure of three-angles", where a "three-angle" is a triangle. The triangle here is formed between (x1, y1), (x2, y1) and (x2, y2).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top