Calculating Tangent Vector from known point on complex element

197 Views Asked by At

Firstly I'm not studying mathematics but I do have a mathematical question relevant to my day job which I'm hoping someone can give me a little advice with.

I'm a CAD guy, that is I draw & 2D/3D model using Computer Aided Design software and the particular issue I have is listed below:

  • I have a list of cartesian coordinates points stored in a CSV file
  • I have complex element (in simple terms, is a combination of lines and arcs with connected into a single graphic element where each elements end-points are connected together save the start and end-points of the complex element)
  • I am working on a VBA project (within the CAD software) which will read the list of coordinates and for each coordinate, will calculate the perpendicular intersection on the complex element from the coordinate point. From these 2No. coordinates I can obviously create a normal vector.

Where I am currently stuck is working out how calculate the tangent vector at this point. Its been 20 years since I last encountered linear algebra/vectors in school and the questions I have searched through so far confuse the hell out of me as they appear far more complex than my issue (not to mention I don't understand the formula symbology...). The reason I am trying to find the tangent vector is to calculate the cross product so I can determine if the source coordinate is on the left or right side of the complex element.

Let me know if uploading some images will help in anyway or if any parts of the question are unclear.

Thanks


Here is a figure that could help visualise the problem:

figure001

1

There are 1 best solutions below

5
On

Starting from your example: Example image from KnightFallz

Let $\color{blue}{\mathbf{B}}$ be the fixed point (Blue), $\color{red}{\mathbf{R}}$ be the changing coordinate (Red), $\mathbf{N}$ be the vector that connects $\color{red}{\mathbf{R}}$ to $\color{blue}{\mathbf{B}}$ (the normal), and $\color{purple}{\mathbf{P}}$ the tangent vector (Pink). The normal vector is given by

$$ \mathbf{N} = \color{blue}{\mathbf{B}} - \color{red}{\mathbf{R}} = \begin{bmatrix}n_x\\n_y\end{bmatrix} ~. $$

Now, say you want to define your tangent vector as the vector that is equal to the $90º$ clockwise rotation from the normal. Then $$ \color{purple}{\mathbf{P}} = \begin{bmatrix}0&1\\-1&0\end{bmatrix} \mathbf{N} = \begin{bmatrix}n_y\\-n_x\end{bmatrix} ~. $$

Therefore you just have to invert the coodinates of you normal vector and take the minus sign of one of them.

Now, if you want $\mathbf{P}$ to always have the same size, you can normalize it and then multiply by a scale factor, $a$.

$$ \mathbf{P}_{\text{normalized}} = \frac{\mathbf{P}}{|\mathbf{P}|} = \frac{1}{\sqrt{n_y^2 + n_x^2}}\begin{bmatrix}n_y\\-n_x\end{bmatrix} $$

Finally,

$$ \mathbf{P}_{\text{final}} = a \mathbf{P}_{\text{normalized}} = \frac{a}{\sqrt{n_y^2 + n_x^2}}\begin{bmatrix}n_y\\-n_x\end{bmatrix} $$


This was to long to write as a comment so I'll reply to your questions here:

The reason I sugested that you normalize the purple line is because you will get a different size for different points. Look at it this way:

  • Your purple line is just a rotated normal line right?
  • But, for different points, the size of the normal line will be different (they are either closer or further from the original point).
  • Therefore, your purple tangent line will get a different lenght for the different points.
  • If that is what you want, fine!
  • But if you want the tangent purple line to always have the same lenght, you need to normalize it!
  • The normalized line has lenght 'unitity' (one).
  • The $a$ parameter just defines your specific constant lenght.
  • It is the same as saying $a \times 1 = a = \text{const.}$.
  • Notice that here, $a$ doesnt change (its a constant) so your line will always have lenght $a$.