Advertisement

Calculating a intersection of a triangle

Started by September 26, 2002 06:02 AM
1 comment, last by CyberGhost 22 years, 4 months ago
This is going to be hard without a diagram......how can I add one? I have two points "y1" (left) and "y2" (right) Lets say their values are 1 and 10 respectively. These are y coordinates...heights. The two points are spaced n world units apart, lets say the variable "units" holds this and its value is 10. x coordinate... given another point "x", which is the distance from point "y1" that we wish to intersect. lets say its value is 4. x coordinate... given this informate i need to calculate y3, which is the height of the intersection of x. which given all the above would in this case be 4. The problem is I cannot for the life of me come up with a simple eqaution to calculate y3. Currently im doing the following.. y3 = y1 + ((y2 - y1)/(units)*x) which given the above would calculate y3 = 4.6 Any ideas....I have a diagram if it helps..
As I understand you, you have two points, P1 = (x1, y1) and P2 = (x2, y2), and you want to determine a third point P3 = (x3, y3) lying on the straight line between P1 and P2. If this is how you mean, your formula is correct and y3 = y1 + x3*(y2 - y1)/(x2 - x1).
Advertisement
Sorry, formula should be y3 = y1 + (x3 - x1)*(y2 - y1)/(x2 - x1).

This topic is closed to new replies.

Advertisement