Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems to me as a very simple and basic question, though I'm having trouble with it.

The Problem

Given a sphere $K\in\mathbb{R}^n$ with radius $r\in\mathbb{R}$ and center $\vec{c}\in\mathbb{R}^n$: $$K:||\vec{x}-\vec{c}||_2^2=r^2$$

And a given line along $\vec{n}\in\mathbb{R}^n$, $||\vec{n}||_2=1$ through $\vec{x}\in\mathbb{R}^n$: $$g: \vec{x}+\vec{n}d$$

Substituting the line into the equation of $K$ gives $$||\vec{x}+\vec{n}d-\vec{c}||_2^2=r^2$$ which results in the quadratic equation $$\sum_{i=1}^{n}(x_i+n_id-c_i)^2-r^2=0$$

Within my problem, it is ensured, that the supporting vector $\vec{x}$ of the line is always within the sphere. With my understanding, this simplifies the solutions of the quadratic equation in such a way, that there are always two solutions for $d$.

The Question

And this is the point, where I got stuck. How can this be rewritten either by using the quadratic formula ($ax^2+bx+c=0 \Rightarrow x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a^2}$) or as a system of equations?

Any help is appreciated. Thank you.

share|cite|improve this question
This has nothing to do with spherical geometry which, perhaps confusingly, is quite unrelated to the geometry of spheres :) – Mariano Suárez-Alvarez Jun 21 '11 at 13:09
Oh, thank you for this remark, @Mariano. I've deleted that tag. – Torbjörn Jun 21 '11 at 13:12
up vote 4 down vote accepted



Now you can solve for $d$.

If you're familiar with dot product the whole thing can be simplified. $$(\vec nd+\vec x- \vec c).(\vec nd+\vec x- \vec c)=r^2$$

$$d^2 \vec n.\vec n + 2d\vec n.(\vec x-\vec c)+(\vec x-\vec c).(\vec x-\vec c)=r^2$$

$$d^2 \|\vec n\|^2 + 2d\vec n.(\vec x-\vec c)+\|\vec x-\vec c\|^2=r^2$$

share|cite|improve this answer
Thanks a lot. It was easy, as I thought. – Torbjörn Jun 22 '11 at 14:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.