line - hyperboloid_twosheets intersection

Equation for line (cartesian)

Equation for hyperboloid_twosheets (cartesian)

Assumed to be centred at 0, the coordinate system origin.

0=-1 + \frac{z^{2}}{c^{2}} - \frac{y^{2}}{b^{2}} - \frac{x^{2}}{a^{2}}

Intersection solutions

Parametric solution (t). Solutions were derived automatically using sympy.

Points in cartesian coordinates (x, y, z)

C Code
x = x0 + (pow(a, 2)*pow(b, 2)*l*z0 - pow(a, 2)*pow(c, 2)*k*y0 - pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(-pow(a, 2)*pow(b, 2)*pow(l, 2) + pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(b, 2)*pow(c, 2));
y = k*(pow(a, 2)*pow(b, 2)*l*z0 - pow(a, 2)*pow(c, 2)*k*y0 - pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(-pow(a, 2)*pow(b, 2)*pow(l, 2) + pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(b, 2)*pow(c, 2)) + y0;
z = l*(pow(a, 2)*pow(b, 2)*l*z0 - pow(a, 2)*pow(c, 2)*k*y0 - pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(-pow(a, 2)*pow(b, 2)*pow(l, 2) + pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(b, 2)*pow(c, 2)) + z0;
x = x0 + (-pow(a, 2)*pow(b, 2)*l*z0 + pow(a, 2)*pow(c, 2)*k*y0 + pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) - pow(b, 2)*pow(c, 2));
y = k*(-pow(a, 2)*pow(b, 2)*l*z0 + pow(a, 2)*pow(c, 2)*k*y0 + pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) - pow(b, 2)*pow(c, 2)) + y0;
z = l*(-pow(a, 2)*pow(b, 2)*l*z0 + pow(a, 2)*pow(c, 2)*k*y0 + pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) - pow(b, 2)*pow(c, 2)) + z0;

Distance inside

Distance between crossing points.

2 \left\lvert{\frac{1}{- a^{2} b^{2} l^{2} + a^{2} c^{2} k^{2} + b^{2} c^{2}} \sqrt{a^{2} b^{2} c^{2} \left(a^{2} b^{2} l^{2} - a^{2} c^{2} k^{2} + a^{2} k^{2} z_{0}^{2} - 2 a^{2} k l y_{0} z_{0} + a^{2} l^{2} y_{0}^{2} - b^{2} c^{2} + b^{2} l^{2} x_{0}^{2} - 2 b^{2} l x_{0} z_{0} + b^{2} z_{0}^{2} - c^{2} k^{2} x_{0}^{2} + 2 c^{2} k x_{0} y_{0} - c^{2} y_{0}^{2}\right)}}\right\rvert

C Code

sol1 = (pow(a, 2)*pow(b, 2)*l*z0 - pow(a, 2)*pow(c, 2)*k*y0 - pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(-pow(a, 2)*pow(b, 2)*pow(l, 2) + pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(b, 2)*pow(c, 2));
sol2 = (-pow(a, 2)*pow(b, 2)*l*z0 + pow(a, 2)*pow(c, 2)*k*y0 + pow(b, 2)*pow(c, 2)*x0 + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2))))/(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) - pow(b, 2)*pow(c, 2));
distance = 2*fabs(sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(l, 2) - pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(a, 2)*pow(k, 2)*pow(z0, 2) - 2*pow(a, 2)*k*l*y0*z0 + pow(a, 2)*pow(l, 2)*pow(y0, 2) - pow(b, 2)*pow(c, 2) + pow(b, 2)*pow(l, 2)*pow(x0, 2) - 2*pow(b, 2)*l*x0*z0 + pow(b, 2)*pow(z0, 2) - pow(c, 2)*pow(k, 2)*pow(x0, 2) + 2*pow(c, 2)*k*x0*y0 - pow(c, 2)*pow(y0, 2)))/(-pow(a, 2)*pow(b, 2)*pow(l, 2) + pow(a, 2)*pow(c, 2)*pow(k, 2) + pow(b, 2)*pow(c, 2)));

Equation for line (spherical)

Equation for hyperboloid_twosheets (cartesian)

Assumed to be centred at 0, the coordinate system origin.

0=-1 + \frac{z^{2}}{c^{2}} - \frac{y^{2}}{b^{2}} - \frac{x^{2}}{a^{2}}

Intersection solutions

Parametric solution (t). Solutions were derived automatically using sympy.

Points in cartesian coordinates (x, y, z)

C Code
x = x0 + (pow(a, 2)*pow(b, 2)*z0*cos(theta) - pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) - pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))*sin(theta)*cos(phi)/(-pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) + pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));
y = y0 + (pow(a, 2)*pow(b, 2)*z0*cos(theta) - pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) - pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))*sin(phi)*sin(theta)/(-pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) + pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));
z = z0 + (pow(a, 2)*pow(b, 2)*z0*cos(theta) - pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) - pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))*cos(theta)/(-pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) + pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));
x = x0 + (-pow(a, 2)*pow(b, 2)*z0*cos(theta) + pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) + pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))*sin(theta)*cos(phi)/(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));
y = y0 + (-pow(a, 2)*pow(b, 2)*z0*cos(theta) + pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) + pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))*sin(phi)*sin(theta)/(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));
z = z0 + (-pow(a, 2)*pow(b, 2)*z0*cos(theta) + pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) + pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))*cos(theta)/(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));

Distance inside

Distance between crossing points.

\sqrt{2} \left\lvert{\frac{1}{- a^{2} b^{2} \cos^{2}{\left (\theta \right )} + a^{2} c^{2} \sin^{2}{\left (\phi \right )} \sin^{2}{\left (\theta \right )} + b^{2} c^{2} \sin^{2}{\left (\theta \right )} \cos^{2}{\left (\phi \right )}} \sqrt{a^{2} b^{2} c^{2} \left(2 a^{2} b^{2} \cos^{2}{\left (\theta \right )} - 2 a^{2} c^{2} \sin^{2}{\left (\phi \right )} \sin^{2}{\left (\theta \right )} + 2 a^{2} y_{0}^{2} \cos^{2}{\left (\theta \right )} - a^{2} y_{0} z_{0} \left(\cos{\left (\phi - 2 \theta \right )} - \cos{\left (\phi + 2 \theta \right )}\right) + 2 a^{2} z_{0}^{2} \sin^{2}{\left (\phi \right )} \sin^{2}{\left (\theta \right )} - 2 b^{2} c^{2} \sin^{2}{\left (\theta \right )} \cos^{2}{\left (\phi \right )} + 2 b^{2} x_{0}^{2} \cos^{2}{\left (\theta \right )} + b^{2} x_{0} z_{0} \left(\sin{\left (\phi - 2 \theta \right )} - \sin{\left (\phi + 2 \theta \right )}\right) + 2 b^{2} z_{0}^{2} \sin^{2}{\left (\theta \right )} \cos^{2}{\left (\phi \right )} - 2 c^{2} x_{0}^{2} \sin^{2}{\left (\phi \right )} \sin^{2}{\left (\theta \right )} + 4 c^{2} x_{0} y_{0} \sin{\left (\phi \right )} \sin^{2}{\left (\theta \right )} \cos{\left (\phi \right )} - 2 c^{2} y_{0}^{2} \sin^{2}{\left (\theta \right )} \cos^{2}{\left (\phi \right )}\right)}}\right\rvert

C Code

sol1 = (pow(a, 2)*pow(b, 2)*z0*cos(theta) - pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) - pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))/(-pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) + pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));
sol2 = (-pow(a, 2)*pow(b, 2)*z0*cos(theta) + pow(a, 2)*pow(c, 2)*y0*sin(phi)*sin(theta) + pow(b, 2)*pow(c, 2)*x0*sin(theta)*cos(phi) + sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) - 1.0L/2.0L*pow(b, 2)*x0*z0*(-sin(phi - 2*theta) + sin(phi + 2*theta)) + pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2))))/(pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2));
distance = sqrt(2)*fabs(sqrt(pow(a, 2)*pow(b, 2)*pow(c, 2)*(2*pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) - 2*pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 2*pow(a, 2)*pow(y0, 2)*pow(cos(theta), 2) - pow(a, 2)*y0*z0*(cos(phi - 2*theta) - cos(phi + 2*theta)) + 2*pow(a, 2)*pow(z0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) - 2*pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) + 2*pow(b, 2)*pow(x0, 2)*pow(cos(theta), 2) + pow(b, 2)*x0*z0*(sin(phi - 2*theta) - sin(phi + 2*theta)) + 2*pow(b, 2)*pow(z0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2) - 2*pow(c, 2)*pow(x0, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + 4*pow(c, 2)*x0*y0*sin(phi)*pow(sin(theta), 2)*cos(phi) - 2*pow(c, 2)*pow(y0, 2)*pow(sin(theta), 2)*pow(cos(phi), 2)))/(-pow(a, 2)*pow(b, 2)*pow(cos(theta), 2) + pow(a, 2)*pow(c, 2)*pow(sin(phi), 2)*pow(sin(theta), 2) + pow(b, 2)*pow(c, 2)*pow(sin(theta), 2)*pow(cos(phi), 2)));


By Johannes Buchner | Source code: https://github.com/JohannesBuchner/intersection | Open a issue or pull request if you would like somthing added