

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

Ok, using Javascript (or something I can easily convert, I know BASIC very well, but a little rusty at C++ and C#) I need to solve this problem/equation:

Given the start and endpoint of a line (in x, y, and z) what point on the line satisfies the equation


A, B, C and D are defined, but x y and z are unknowns, but are somehwere on that line I know above. I need to get an x, y, and z of the point back from this.

share|improve this question
Can you paste your psudo code first? – Jay Zeng Jan 27 '10 at 4:10

Since you know the start and end point of the line, you can get the equation of line in the form ax + by + cz = 0

A*x + B*y + C*z = 0 can be written as (A/D)*x + (B/D)*y + (C/D)*z = 1, which is again an equation of a line.

I guess what you are seeking is the intersection point of the two lines.

Solve the two equations and you will get your x, y and z. Actually these equations are a system of 3 variable equations.

I hope this helps.


share|improve this answer
Are you sure you don't mean (A/D)*x + (B/D)*y + (C/D)*z -1 = 0 ? I got that from taking the equation given in the problem, dividing both sides by D, and then subtracting 1. – Alexander Bird Jan 27 '10 at 4:21
Yes, you are right. My bad. Updated response. Thanks :) – Arnkrishn Jan 27 '10 at 13:52
I've seen it two ways, one with a negative D and one with a positive. It doesn't matter as long as you keep it consistent. But, I know how to solve. How do I convince JS to solve it? To feed in the line's equation and the plane's a b c and d and get out the x y z of the point they intersect? I know they will intersect, too, as I will only feed in points on the other side of the plane from the start point. – user2301457 Jan 27 '10 at 23:34

Your Answer


