# Line representation using dot product and cross product

From the 2.4.1 section of the attached book:

Equation $$ax+by=c$$ can be interpreted geometrically through dot product: if we consider $$(a,b)$$ as a vector, then the equation becomes $$(a,b)·(x,y) =c$$. This vector is perpendicular to the line, which makes sense: we saw in 2.3.1 that the dot product remains constant when the second vector moves perpendicular to the first.

The way we’ll represent lines in code is based on another interpretation. Let’s take vector $$(b,−a)$$, which is parallel to the line. Then the equation becomes a cross product $$(b,−a)×(x,y) =c$$. Indeed, we saw in 2.3.2 that the cross product remains constant when the second vector moves parallel to the first.

In this way, finding the equation of a line going through two points $$P$$ and $$Q$$ is easy: define the direction vector $$\vec{v} = (b,−a) = \vec{PQ}$$, then find $$\vec{v}×P$$.

I know that $$ax+by$$ equivalent to $$(a,b)·(x,y)$$ using dot product, but I can't understand what does the author mean in the following sentence "the dot/cross product remains constant when the second vector moves perpendicular/parallel to the first".

Also, moving to the equation $$\vec{v} = (b,−a) = \vec{PQ}$$ is still ambiguous for me.

kindly, write down omitted steps and some helpful drawing if it's possible.

• The idea is this: if $v \perp w$ then $v \cdot w = 0$, so if $(c,d)\perp (a,b)$ then $(a,b) \cdot [(x,y)+(c,d)] = (a,b) \cdot (x,y) + (a,b) \cdot (c,d) = (a,b) \cdot (x,y)$ – dcolazin Apr 30 '19 at 23:44
• The cross product doesn’t remain constant when the second vector moves perpendicular to the first. Indeed, as is stated in the quoted block, is remains constant when the movement is parallel, not perpendicular. – amd Apr 30 '19 at 23:49
• Sorry, but as a non-native speaker of English, I can't understand (or I'm not sure) how does a vector move perpendicular or parallel to another one. – Abdulkader May 1 '19 at 0:14
• See @dcolazin’s comment. – amd May 1 '19 at 0:40
• @dcolazin If I'm not wrong, you mean that for any two vectors $\vec{u}$ and $\vec{v}$, if we add a vector $\vec{w}$ to $\vec{v}$ where $\vec{w} \perp \vec{u}$, then $\vec{u}\cdot\vec{v}=\vec{u}\cdot(\vec{v}+\vec{w})$, and this operation means that vector $\vec{v}$ moves perpendicular to vector $\vec{u}$. – Abdulkader May 1 '19 at 1:19

Given two vectors $$\vec{u}$$ and $$\vec{v}$$ in Cartesian coordinates:

The dot product $$\vec{u}\cdot\vec{v}$$ remains constant when $$\vec{v}$$ moves perpendicular to $$\vec{u}$$.

That is because if we add a vector $$\vec{w}$$ to $$\vec{v}$$, where $$\vec{w} \perp \vec{u}$$:

Then $$\vec{u}\cdot(\vec{v}+\vec{w})=\vec{u}\cdot\vec{v}+\vec{u}\cdot\vec{w}=\vec{u}\cdot\vec{v}+0=\vec{u}\cdot\vec{v}$$.

The cross product $$\vec{u}\times\vec{v}$$ remains constant when $$\vec{v}$$ moves parallel to $$\vec{u}$$.

That is because if we add a vector $$\vec{w}$$ to $$\vec{v}$$, where $$\vec{w} \parallel \vec{u}$$:

Then $$\vec{u}\times(\vec{v}+\vec{w})=\vec{u}\times\vec{v}+\vec{u}\times\vec{w}=\vec{u}\times\vec{v}+0=\vec{u}\times\vec{v}$$.

Also, we can obtain the vector $$\vec{v'}=(b, -a)$$ from $$\vec{v}=(a, b)$$ as the following:

$$\left[ \begin{array}{cc} \cos(-90^{\circ}) & -\sin(-90^{\circ}) \\ \sin(-90^{\circ}) & \cos(-90^{\circ}) \end{array} \right] \left[ \begin{array}{c} a \\ b \end{array} \right] = \left[ \begin{array}{c} b \\ -a \end{array} \right]$$

Where the first matrix is a rotation matrix.