1
$\begingroup$

Suppose I have a line segment along a unit vector $\ell$ (so $-\ell$ is equally valid) and a vector $v$.

If I want to perturb $v$ towards $\ell$, I can just add a vector $\vec{d}=\alpha(\ell-v)$ to $v$.

However, suppose I want to perturb $v$ to the closer of $\ell$ and $-\ell$. I.e. choose $d$ such that $$ \vec{d} = \alpha(f - v) $$ where $$ f = \arg\min_{r\in\{f,-f\}} ||r-v|| $$

In other words, I want to perturb $v$ to the closer of $f$ and $-f$.

Is it possible to write this without taking the min or using an "if"?

$\endgroup$

1 Answer 1

2
$\begingroup$

If the angle between $\mathbf{\ell}$ and $\mathbf{v}$ is less than a right angle then you want

$$ \mathbf{d=\ell-v} $$

otherwise you want

$$ \mathbf{d=-\ell-v} $$

This can be achieved in one equation with

$$ \mathbf{d=\left(\frac{\ell\cdot v}{\vert \ell\cdot v\vert}\right)\ell-v} $$

If you only wish to "nudge" $\mathbf{v}$ in the proper direction you can select a constant $0<\alpha<1$ and use

$$ \mathbf{d}=\alpha\left[\mathbf{\left(\frac{\ell\cdot v}{\vert \ell\cdot v\vert}\right)\ell-v}\right] $$

If the angle between $\mathbf{\ell}$ and $\mathbf{v}$ is a right angle, then you will have

$$ \mathbf{d}=-\alpha\mathbf{v}$$

Subtraction of vectors

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .