An LWPOLYLINE holds its vertices itself, in its own coordinate system. Only the X and Y of a vertex are written, groups 10 and 20; Elevation places all of them along the normal.
Width is a width every segment shares. When they differ, empty it and give each vertex its Widths: the segment from that vertex starts at Start and ends at End.
A vertex’s Bulge makes the segment from it an arc: the tangent of a quarter of the arc’s angle, so 1 is a half circle and 0 a straight segment. Flags 1 closes the polyline with a segment from the last vertex back to the first, which takes the last vertex’s bulge and widths.
A POLYLINE keeps its vertices as VERTEX entities that follow it in the file. Flags 8 makes it a 3D polyline: its vertices are in world coordinates, and each takes flag 32.