views:

70

answers:

1

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*x+B*y+C*z=D

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.

+1  A: 

Hi

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.

cheers

Andriyev
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.
Thr4wn
Yes, you are right. My bad. Updated response. Thanks :)
Andriyev
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.