Uh, what do a and b represent here? Vectors, you say? Does that mean the same thing as "line segments?"

A Vector is a line segment where the first endpoint is in the origin (0, 0). This means that a Vector only represent the direction and length of a line. So a and b represents the direction and length of the two line segments.

what does "dot" mean?

dot stands for dot product, also called scalar product. Is one of two ways you can multiply vectors. Is defined as "the product of two vectors to form a scalar, whose value is the product of the magnitudes of the vectors and the cosine of the angle between them"

And what does "|a|" mean? From context, I assume it represents a "normalized" vector, but I don't know what that is. You show me the calculations for normalization later on in your post, but I have no idea what you're doing or why.

|a| means the length of vector a. Let's look at the formula:

a dot b = |a||b|cos angle

we wan't to solve this to get angle:

cos(angle) = (a dot b) / (|a| |b|)

Normalizing a vector means making the length of the vector equal 1. This makes |a| |b| become 1*1. So if a and b is normalized the formula becomes:

cos(angle) = (a dot b)/(1 * 1)

cos(angle) = (a dot b)

finally to solve the equation:

angle = Math.acos(a dot b).

(a dot b) returns a single value not a vector.

The Vectors are normalized by dividing x and y with the length of the Vector.

"Subtract x,y,z?" Hah? It looks to me like A and B are points, here, since they're derived by subtracting one point from another, but I'm not sure how you do that. Subtract A1.x from A2.x and A1.y from A2.y?

Yes, subtracting the points. So

C = B - A

means

C.x = B.x - A.x

C.y = B.y - A.y

Wich makes C a Vector. Because we have moved the line segment (A, B) so that it A starts in origo (0, 0).

What is this "z" I keep hearing about?

That is the third dimension

I was not sure if you used 2d or 3d lines. The algorithm is identical.

What does "/=" do?

This is java code. "A.x /= ALength" is the same as A.x = A.x / ALength". It's just a little less code.

Finally, exactly what angle does this calculation produce?

Given the lines A and B represented by the enpoints (A1, A2) and (B1, B2). This calculation gives you the angle between the lines in the range 0 throug pi. The order of the endpoints matter because it defines the direction of the Vectors. The lines do not have to intersect. You can think of it as the lines are moved to the intersection point of the rays (infinite lines not segments), where the calculations is done.

It gives you the absolute angle of the two vectors A and B. Absolute angle means there are two solutions. The second solution is (2*PI-angle). To find out wich to use you can use the "cross-product"

If you want understand it better you can read up (google) on vector math. I found this when I searched for "angle between lines":

http://www.netcomuk.co.uk/~jenolive/vect14.html