title: Calculating the distance of vectors along an arbitrary normal
body: <p>I'm trying to create a function for extruding a face along a normal by dragging the mouse. For the purpose of the question, I've simplified things to 2D vectors, so that the view is looking down onto a cube, with the normal being that of the face to extrude.</p>
  <p>I can limit the movement of the mouse by the direction of the face normal easily, my question is how to work out the correct distance along the normal direction that the mouse has travelled.</p>
  <p>I have two vectors (A &amp; B1). A is the starting point and B1 is the current mouse position (see image <a href="https://i.stack.imgur.com/i6EHA.jpg" rel="nofollow noreferrer">Vector Normal Projection</a>). I need to project B1 so that it points along the face normal direction from point A. So B1 becomes B2. This will also be the case for a mouse position of Bx (Bx needs to be projected from A along the normal so that it becomes B2). This will mean that whether the mouse is at B1, B2 or Bx they will all give the same distance along the normal direction (2 in this case).</p>
  <p>I may be approaching the problem incorrectly, so please let me know if there is a better way to tackle this.</p>
  <p>Thanks. </p>