Calculate coordinates from normal vector and center

156 Views Asked by At

Lets say I have 2D plane, normal vector, and X,Y coordinates of center of the line. How can I calculate start point of the line and end point of the line? (lets say length of line is 100mm but it doesnt matter).

Edit: I have center of the line and normal vector and I need to calculate both ends of the line like their positions X,Y.
image is here

1

There are 1 best solutions below

0
On BEST ANSWER

If the normal vector is $\large n = (n_x, n_y)$ , then from this you can compute the direction vector of the line segment as $\large d = (n_y, -n_x) $. Normalize vector $d$ by dividing by its length to obtain vector $\hat{d}$ as follows

$\large \hat{d} = \dfrac{ (n_y, -n_x) }{\sqrt{ n_x^2 + n_y^2} } $

Now if the midpoint of the line segment is $M = (m_x, m_y)$ and its length is $L$, then the endpoints are

$\large A = M + \left(\dfrac{L}{2}\right) \hat{d}$

and

$\large B = M - \left(\dfrac{L}{2}\right) \hat{d}$