3d Maths - finding points on a plane with conditions

48 Views Asked by At

I'm writing some software to plot a 3D line (with a given width) given two endpoints. I'm trying to work out the maths for how to calculate the vertices for the line. Image of problem.

So I know in this case, that with one endpoint(a,b,c) and the direction of the line(A,B,C), I can find the equation of the plane that the vertices will lie in:

A(x-a) + B(y-b) + C(z-c) = 0

I also know that all 4 points are equidistant from the endpoint, which will be a sphere:

(a-x)^2 + (b-y)^2 + (c-z)^2 = Sqrt(2) * width

I also know that the top and bottom parts of the line will always be parallel with the x-y plane, which leads to:

A(x1-x2) = B(y2-y1)

(Where x1,y1,z1 and x1,y2,z2 are vertices on the top/bottom parts of the line adjacent to each other)

But I still have more unknowns than equations and I can't figure out where to go from here.

1

There are 1 best solutions below

0
On

We can find a unit vector $\hat n$ along the direction of the line, a unit vector $\hat u$ perpendicular to $\hat n$ and parallel to $xy$ plane, a unit vector $\hat v$ perpendicular to both $\hat n$ and $\hat u$, as follows: $$ \hat n={(A,B,C)\over\sqrt{A^2+B^2+C^2}},\quad \hat u={(B,-A,0)\over\sqrt{A^2+B^2}},\quad \hat v= \hat u\times\hat n={(-AC,-BC,A^2+B^2)\over\sqrt{A^2+B^2}\sqrt{A^2+B^2+C^2}}. $$ Then the vertices you need are given by: $$ (a,b,c)\pm{w\over2}\hat u\pm{w\over2}\hat v, $$ if $w$ is the width of the line.