Try this I am still calculating :) improving... Let me know if it works.
A = (x1,y1,z1)
B = (x2,y2,z2)
C = (x,y,z)
C will divide line joining A and B in ratio x1/x2
.
So by similarity (y,z) will also divide line joining (y1,z1) and (y2,z2) in the same ratio.
As the point C lies in Y-Z plane
x = 0
by Section Formula
y = (r*y2 + y1) / (r+1)
z = (r*z2 + z1) / (r+1)
where r = |x1| / |x2|
Simple example:
Let A = (1,2,2)
and B = (-2,2,2)
then C
should clearly be (0,2,2)
.
x = 0
r = 1 / 2 = 0.5
y = (0.5*2 + 2)/(0.5+1) = 2
z = (0.5*2 + 2)/(0.5+1) = 2
CODE C#:
public class Point
{
public double x { get; set; }
public double y { get; set; }
public double z { get; set; }
public Point(double X, double Y, double Z)
{
x = X;
y = Y;
z = Z;
}
public override string ToString()
{
return string.Format("({0},{1},{2})",x,y,z);
}
}
public class Program
{
public static void Main()
{
Point a = new Point(-10, 0, 10);
Point b = new Point(10, 0, 0);
Console.WriteLine(GetIntersectionWithYZ(a,b));
}
public static Point GetIntersectionWithYZ(Point A, Point B)
{
double r = - A.x / B.x;
double y = (r * B.y + A.y) / (r + 1);
double z = (r * B.z + A.z) / (r + 1);
return new Point(0, y, z);
}
}