Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

Let say I have a given point and a line. The point may be on the line or not. How to make sure that this line remains in place, while I need to move the point to the line, only if it is not on the line. See this image:

enter image description here

share|cite|improve this question

closed as not a real question by BenjaLim, Henning Makholm, Leonid Kovalev, Chris Eagle, rschwieb Aug 14 '12 at 16:59

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Could you perhaps rephrase the last two sentences? What do you mean by line always remaining on line and moving line only if it is not on line? – T. Eskin Apr 23 '12 at 11:52
@ThomasE., I have added an image – user960567 Apr 23 '12 at 11:58
What do you mean by "line remain on line"? – dtldarek Apr 23 '12 at 11:58
Why should we expect that the point won't remain on the line if you place it on the line? Your question implies some dynamical process, but you don't provide any context. -1 – Raskolnikov Apr 23 '12 at 12:07
Are you looking for the general formula for a general line through a fixed point? – Mark Bennet Apr 23 '12 at 12:23
up vote 4 down vote accepted

In case you are asking how to project point onto a line, then there is a simple formula for an orthogonal projection which can be done as follows. Let $v$ be the vector denoting the line, then

$$x' = \frac{\langle v, x \rangle}{\langle v, v \rangle}\cdot v$$


$$ \langle a, b \rangle = \sum_i a_i\cdot b_i $$

is the standard scalar product. In 2D the whole formula will look like below:

let $P = (P_x, P_y)$ and $Q = (Q_x, Q_y)$ will be two points the line passes through, then $v = P-Q = (P_x-Q_x, P_y-Q_y)$ and the projection of $R = (R_x, R_y)$ denoted as $R' = (R_x', R_y')$ can be calculated by the formula:

$$(R_x', R_y') = \frac{(R_x-Q_x)\cdot v_x + (R_y-Q_y)\cdot v_y}{v_x^2+v_y^2}\cdot(v_x, v_y) + (Q_x, Q_y).$$

Of course this can be easily generalized to higher dimensions. Cheers!

share|cite|improve this answer
Yes. Thanks. Why so many -ve votes. – user960567 Apr 23 '12 at 17:41

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