How do I calculate the gravitational force that a line-segment of uniform mass exerts on a point in 3D space? For my purposes:

*

*The point can be assumed to always have a mass of 1.

*The mass of the line is uniform, and directly proportional to its length.

Here is what I have so far:
Let the line start at point $A$ and end at point $B$.
Let $P$ be the point that the line $\overline{\rm AB}$ exerts gravitational force on.
Let $L$ be the length of the line $\overline{\rm AB}$.
I first define a function:
$$
f(t)=A+t(B-A)
$$
This gives us the point $t$ of the way from $A$ to $B$. For example, at $t=0$, $f(t)$ yields $A$, while at $t=1$, $f(t)$ yields B. $f(.5)$ gives us the point directly in the middle of $\overline{\rm AB}$.
Next I define a function:
\begin{align}
g(t)&=(A+t(B-A))-P\\
&=A-P+t(B-A)\\
Let\ y&=A-P\\
Let\ z&=B-A\\
g(t)&=y+tz
\end{align}
This gives us the vector from point $P$ to the point on the line $\overline{\rm AB}$ that is at $f(t)$. This is useful in that it gives a direction of the force of gravity that a point at $f(t)$ exerts on point $P$. Also, it's length is relevant in the calculation of the net force of the gravity.
Next I define a function:
\begin{align}
h(t)&=(y+tz)^T\cdot(y+tz)\\
&=\|y\|^2+2t(z{\cdot}y)+t^2\|z\|^2\\
Let\ c&=\|y\|^2\\
Let\ d&=(z{\cdot}y)\\
Let\ e&=\|z\|^2\\
h(t)&=t^2e+2td+c=r^2\\
\end{align}
This gives me the squared length of $g(t)$. This is needed in my equation for gravity, which is:
\begin{align}
Force\ of\ gravity\ on\ P&=G\frac{m_1m_2}{r^2}\\
&=G\frac{m_1}{r^2}\\
&=\frac{m_1}{r^2}\\
m_1&=Ldt\\
Force\ of\ gravity\ on\ P&=\frac{L}{r^2}dt
\end{align}
$m_2$ is always one, and so I remove that term. I remove $G$ because I don't care about the gravitational constant in this context. As I am evaluating the gravity exerted from a line of uniform mass proportional to its length, $m_1$ is relative to $L$ and change in $t$. $Ldt$ gives me the mass of a segment of the line. With this, it is my understanding that I can now find the total net force of gravity with:
\begin{align}
Net\ force\ of\ gravity&=L\int_{0}^{1}\frac{1}{r^2}dt\\
&=L\int_{0}^{1}\frac{1}{t^2e+2td+c}dt\\
\end{align}
I am not quite there yet though, because I want to know which direction this force is in. I can extract the individual $x$, $y$, and $z$ components from the vector: $y+tz$ but they must be normalized before they are multiplied by $L$ as they have a length $r$. Then force vector then becomes:
\begin{align}
Force\ of\ gravity&=
\begin{bmatrix}
L\int_{0}^{1}\frac{\frac{y[x]+tz[x]}{r}}{t^2e+2td+c}dt&\ L\int_{0}^{1}\frac{\frac{y[y]+tz[y]}{r}}{t^2e+2td+c}dt&\ L\int_{0}^{1}\frac{\frac{y[z]+tz[z]}{r}}{t^2e+2td+c}dt
\end{bmatrix}\\
&=
\begin{bmatrix}
L\int_{0}^{1}\frac{y[x]+tz[x]}{(t^2e+2td+c)^\frac{3}{2}}dt&\ L\int_{0}^{1}\frac{y[y]+tz[y]}{(t^2e+2td+c)^\frac{3}{2}}dt&\ L\int_{0}^{1}\frac{y[z]+tz[z]}{(t^2e+2td+c)^\frac{3}{2}}dt
\end{bmatrix}
\end{align}
This is where I am stuck. I do not know how to integrate with respect to $t$ for an arbitrary $A$, $B$, and $P$. Actually, even if I choose a specific $A$, $B$, and $P$, I still get stuck. For example:
\begin{align}
Let\ A&=
\begin{bmatrix}
5 & 7 & 0
\end{bmatrix}\\
Let\ B&=
\begin{bmatrix}
2 & 2 & 0
\end{bmatrix}\\
Let\ P&=
\begin{bmatrix}
8 & 3 & 0
\end{bmatrix}\\
Force\ of\ gravity&=
\begin{bmatrix}
\sqrt{34}\int_{0}^{1}\frac{-3t-3}{(34t^2-22t+25)^\frac{3}{2}}dt&\ \sqrt{34}\int_{0}^{1}\frac{-5t+4}{(34t^2-22t+25)^\frac{3}{2}}dt&\ 0
\end{bmatrix}
\end{align}
How would I integrate this, and how would I integrate for arbitrary points? The reason why I want to find an integration for an arbitrary $A$, $B$, and $P$ is because I need a program to quickly calculate gravity from a line segment for any $A$, $B$, and $P$.
 A: The force clearly lies in the plane containing the point mass and the line segment.  If the end points of the line segment are $A$ and $B$ and the point mass is at $C$, then define
$v_1 = B - A $
$v_2 = C - A $
The vector $ N = v_1 \times v_2 $ is perpendicular to this plane containing the line segment $AB$ and point $C$.  Now define a reference frame $O'x'y'z'$ with its origin at point $A$ and its $x'$ axis extending along $AB$, i.e. along $v_1$, so we'll take
$ \hat{x'} = \dfrac{v_1}{\| v_1 \|} $
to be the unit vector along the $x'$ axis.  And we'll take the $z'$ to extend along $N$ , i.e.
$ \hat{z'} = \dfrac{N}{\| N \| } $
will be the unit vector along the $z'$ axis.  Finally the unit vector along the $y'$ axis is given by
$ \hat{y'} = \hat{z'} \times \hat{x'} $
Now we have completely specified the reference frame $O'x'y'z'$, hence a point P in $Oxyz$ (the world frame) is related to its position vector in the $O'x'y'z'$ by
$ P = A + R P' $
where $ R = [\hat{x'} , \hat{y'} , \hat{z'} ] $
From here, we can find the position vectors of $A,B,C$ in the frame $O'x'y'z'$ as follows
$ A' = [0, 0, 0]^T$
$ B' = R^T (B - A) = [ a, 0, 0 ] $
$C' = R^T (C - A) = [ b ,c, 0 ] $
So now the line segment in the $O'x'y'z'$ frame extends from $(0,0,0)$ to $(a,0,0) $ and point $C$ is at $(b,c,0) $
The force lies in the $x'y'$ plane.  Take a differential element of length $dt$ at position $x' = t$ (i.e. its position is $r = (t, 0, 0)$, then the force acting on the mass point is
$\mathrm dF =  \lambda \dfrac{(r - C) dt}{\| r - C \|^3} = \lambda \dfrac{(t - b, -c) \mathrm dt }{ ((t - b)^2 + c^2)^{3/2} }$
($\lambda$ is the mass density of the line segment per unit length)
And the force will be
$ F = \lambda \displaystyle \int_{0}^a \dfrac{(t - b, -c) \mathrm dt }{ ((t - b )^2 + c^2)^{3/2} } = \lambda \int_{-b}^{a - b} \dfrac{ (u, -c) \mathrm du }{ ( u^2 + c^2)^{3/2}} \\
= \lambda \left( \bigg[ - \dfrac{1}{\sqrt{u^2 + c^2}} \bigg]_{-b}^{a-b} , \bigg[ -\dfrac{ u}{c \sqrt{u^2 + c^2}} \bigg]_{-b}^{a-b } \right) \\= \lambda \left( - \dfrac{1}{\sqrt{(a-b)^2 + c^2}} + \dfrac{1}{\sqrt{b^2 + c^2}} , - \dfrac{a-b}{c \sqrt{(a-b)^2 + c^2}} - \dfrac{ b  }{c \sqrt{ (b^2 + c^2 } } \right) $
Now that we have $F = (F_x, F_y) $ in the $O'x'y'z'$ we can compute this vector in the $Oxyz$ (world frame) as follows
$ F = R [F_x, F_y, 0]^T  = F_x \hat{x'} + F_y \hat{y'} $
