Equation for a straight line in Cartesian space
I am trying to create a straight line in the Cartesian space made from two points that have (x,y,z) coordinates. This is for a making a robot arm move in a straight line, I would input two points and the math would give me back a certain numbers of points that create a straight line from point A to point B. The robot arm moves on a circular base.
I think I should use the equation of a line: $ax + by + c = 0$.
But I'm not exactly sure how I would get the intermediate points from that and if it works for 3 dimensions. If this is to vague let me know and I can further clarify.
Solution 1:
The equation you gave, $ax+by+c=0$, is the equation for a line in two dimentions. In three dimensions, you can define a line by a point and a vector. This is not in contradiction with the idea that two points determine a line, as obviously there is a vector between two points and therefore by specifying two points you have also specified a point and a vector. This is probably all too pedantic to be worthwhile discussing further, so let's move on to the specific useful example.
Let one point be defined as $P=(x_p,y_p,z_p)$, and another point be defined as $Q=(x_q,y_q,z_q)$. Then we can define the line $L$ as follows:
$$L=\{P+t(Q-P)\}$$ where $t$ is any real number. To dissect this a little bit, this shows us that $P$ is in the set (for $t=0$), and $Q$ is in the set (for $t=1$). By allowing $t$ to be any real number, we are scaling the vector between $P$ and $Q$, and this is what gives us the whole line.
Now, we consider any arbitrary point on the line, which we will define as $(x,y,z)$. If this point is on the line, then it is in the set $L$ and so we must have $$\begin{align}x=&x_p+t(x_q-x_p)\\ y=&y_p+t(y_q-y_p)\\ z=&z_p+t(z_q-z_p) \end{align}$$ These equations are parametric, that is they depend on a parameter $t$, but such equations are necessary in order to describe a line in three dimensions. Obviously, if the line happened to be in one of the planes, say the $xy$ plane, then $z_p=z_q=0$, and so the equations could be solved for $t$. Substituting, you would get the familiar two-dimensional equation for a line, however in general the best you can do is solve for $t$ in the above equations and reduce the three equations to two.
It is also common to write the so-called "symmetric" equations for a line in three dimensions by solving for $t$ and setting all three equal to each other, like so: $$\frac{x-x_p}{x_q-x_p}=\frac{y-y_p}{y_q-y_p}=\frac{z-z_p}{z_q-z_p}$$
Unfortunately, I don't think these sorts of equations will help with your robot project, but perhaps the discussion will engender some good ideas. You can take a look at Paul's Online Notes for more discussion about how lines are represented in three dimensions. He doesn't follow exactly the same approach as I have outlined here, but it is very similar.
You mentioned that the robot arm is on a circular base, and as such it might be advantageous to look into using Spherical Coordinates (which may simplify many of the computational aspects of movement).
Solution 2:
parameterized formula for a line through 2 points $P_1=(x_1,y_1,z_1)$ and $P_2=(x_2,y_2,z_2)$
$$\begin{cases} x=x_1+t\cdot(x_2-x_1) \\ y=y_1+t\cdot(y_2-y_1) \\ x=z_1+t\cdot(z_2-z_1) \\ \end{cases}$$
vary $t$ to get a sample of points where $t\in[0,1]$ gives points $\in[P_1,P_2]$
you can also use the weighted average of the 2 points
$$\begin{cases} x=t\cdot x_1+(1-t)\cdot x_2 \\ y=t\cdot y_1+(1-t)\cdot y_2 \\ x=t\cdot z_1+(1-t)\cdot z_2 \\ \end{cases}$$
again $t\in[0,1]$ for points $\in[P_1,P_2]$
you can eliminate the $t$ so you get 2 formulas (as the intersection of 2 planes)