# Find E-field due to an arbitrary finite line of charge at arb point

## Homework Statement

Hi everyone. This isn't homework.. I've been out of school for almost a decade; but rather this is for an opengl simulator i'm building.

The integrals for the E and B fields of a finite line of moving-charge are well known and can be found in textbooks and online--even on this very forum. But one thing I've noticed is the setup is always the same: the line of charge restricted to an axis (usually the x-axis) and the point is raised some distance above the line. Solving is straightforward, we consider the line a bunch of individual charges and use an integral to evaluate using superposition, handling x and y separately. To solve for sin(theta) and cos(theta), we use the law of triangles, and things fall into place easily due to our setup.

However, my simulator is supposed to work in 3d. Furthermore my lines are arbitrary. To make the integral solvable, I change the reference frame temporarily such that the line resides on the X axis. Also the plane containing the point and line is oriented such that all three points share the same Z-value (basically set it up exactly like the textbook method so that it can be solved).

I do this by taking the cross product between the X-axis and my line, find the angle between this cross product and and x axis. Then axis-angle rotate the frame about the cross product by the given angle needed to align the line straight on the X-axis. Then I transform the normal of the plane that contains everything by the signed angle between it and the Z-axis, and rotate the frame by that angle around the X-axis. This neat little trick basically turns a disgusting 3D line of arbitrary slope and a random point into a line that has the same y-z values (only varies in X) and a point that has the same z value (only varies in x,y) =]. Please see the image attached:

[PLAIN]http://authman.net/quaternion.jpg [Broken]

At this point, integration is rather simple... but it seems like there is a lot of room for optimizations. Instead of doing this change of reference frame, performing the text-book integration, then changing back to the original reference frame, I figured I could probably speed up my simulator by figuring out how to integrate directly -- in other words how to find the electric field due to an arbitrary finite line of charge at some arbitrary point.

After I see an example of how the E field integral is set up, I could apply the same techniques to calculate the B field. Also, since the 3d equations would be messy, I would be more than ecstatic with just the 2D equations -- again, once I see how it's done for 2D, I can extrapolate the knowledge and apply it to 3D. But I've been out of school for a while, and even though I've spent the better part of the past few weeks going over my vecalc and physics books, the solution seems to have yet evaded me.

## The Attempt at a Solution

Okay, in my head, I figured I could try to do the same thing we do for the textbook style integrator, namely set up equations for Ex and Ey. Since both x and y are varying, I could calculate y as f(x) since I have the equation of the line. You can see the initial work in this image.

[PLAIN]http://authman.net/work.jpg [Broken]

However I'm stuck for a few reasons. First, even if I have the lengths of the sides of the differential triangles, they still aren't aligned with my axes so I cant just multiply by sin/cos theta to get the x/y components. Also because of the line is made up say (10,10,10) (10,20,30), the difference in x will be zero and the limits of the integral will be from 10 to 10, which would give me and answer 0 for Ex, Ey and Ez. What i'm looking for is some direction =/.

## The Attempt at a Solution

Last edited by a moderator: