0

I have 3 (cartesian) points: v0, v1 and v2 whose values are shown below:

enter image description here

I need to calculate the points p0, p1 and p2 given that d may be any distance perpendicular from the midpoint of any two vertices.

For example, p0 is found by taking the midpoint of v1 and v2 and then moving perpendicular a distance d to find p0. I can find the midpoints, but after that, I am unsure how to find p0, p1 and p2 (as my 3d cartesian/vector math is very limited).

If an example could be given to show how to calculate (step by step) the values of p0, p1 and p2 that would be very much appreciated.

bdcoder
  • 145

2 Answers2

0

I give you the formula for $p_0$, the other points are calculated similarly. First calculate the midpoint $m$ of $v_1,v_2$, which is simply $m=(v_1+v_2)/2$. Then $p_0$ lies on the line from $v_0$ through $m$, i.e. $p_0=v_0+\lambda\cdot\frac{m-v_0}{||m-v_0||}$, where $\lambda$ is the desired distance from $p_0$ to $v_0$. Thus, $\lambda=||m-v_0||+d$. Our final result should be \begin{align*} p_0=v_0+\frac{||m-v_0||+d}{||m-v_0||}\cdot(m-v_0)=v_0+\left(1+\frac{d}{||m-v_0||}\right)(m-v_0). \end{align*} Here, $||x||$ is the Euclidian norm of $x$, which is for $x=(x_1,x_2,x_3)\in\mathbb R^3$ just $||x||=\sqrt{x_1^2+x_2^2+x_3^2}$.

Here is an example: Let's say $v_0=(1,0,1),v_1=(1,1,-2),v_2=(3,-1,4),d=3$. Then $m=(v_1+v_2)/2=(4,0,2)/2=(2,0,1)$. Then $m-v_0=(1,0,0)$, hence $||m-v_0||=\sqrt{1^2+0^2+0^2}=1$. Finally, \begin{align*} p_0=v_0+\left(1+\frac{d}{||m-v_0||}\right)(m-v_0)=(1,0,1)+4(1,0,0)=(5,0,1). \end{align*}

sranthrop
  • 8,497
  • Thank-you very much for providing the equation -- however, my vector math is very rusty... is the || ... || mean the normalized form of m - v0? and are we using the dot product or cross product? -- this is where I need an example that shows exactly how the numbers are used in the equations. My apologies as I have not done any of this type of math in at least 30 years! – bdcoder Jul 30 '17 at 15:39
  • Hey, no problem. Yes, $||x||$ is the length of the vector $x$. Example: If $x=(1,2,3)$, then $||x||=\sqrt{1^2+2^2+3^2}=\sqrt{14}$, and so $\frac{x}{||x||}=(1/\sqrt{14},2/\sqrt{14},3/\sqrt{14})$ is the normalized version of $x$. There is no dot product and no cross product involved in my formula... Where did you find this? – sranthrop Jul 30 '17 at 17:08
  • Btw: I added an example. – sranthrop Jul 30 '17 at 17:19
  • Thanks srandthrop! (I mistakenly took the dot in your formula as a vector "dot" instead of a multiplication; that is how rusty I am) -- in any case, I should be able to muddle through this now. Thanks again! – bdcoder Jul 30 '17 at 19:58
  • You're very welcome. Please, don't hesitate to ask again if there are any further questions! – sranthrop Jul 30 '17 at 22:04
0

You can compute the midpoint of two vertices by averaging the coordinates, so the point between $v_1$ and $v_2$ is $\frac 12(v_1+v_2)$ in each axis. Call it $v_4$Now you have two points on the line through $v_0$ and $v_4$, so you can parameterize the line as $v_4+t(v_0-v_4)$. To get the right distance you just want $d=\pm t|v_0-v_4|$ where you have to choose the sign to get the right side of the line.

Ross Millikan
  • 374,822
  • Right -- I can compute the midpoint (v4) -- and I have found the equation you gave, IE: "parameterize the line" from other posts, but my vector math is lacking and I must be doing something wrong as the final point always ends up nowhere near where it should be. – bdcoder Jul 30 '17 at 15:47
  • Ross - thank-you! This works as well -- once I corrected my math deficiencies ! :) – bdcoder Aug 01 '17 at 01:53