This paper studies the problem of determining the sensor locations in a large sensor network using only relative distance (range) measurements. Based on a generalized barycentric coordinate representation, our work generalizes the DILOC algorithm to the localization problem under arbitrary deployments of sensor nodes and anchor nodes. First, a criterion and algorithm are developed to determine a generalized barycentric coordinate of a node with respect to its neighboring nodes, which do not require the node to be inside the convex hull of its neighbors. Next, for the localization problem based on the generalized barycentric coordinate representation, a necessary and sufficient condition for the localizability of a sensor network with a generic configuration is obtained. Finally, a new linear iterative algorithm is proposed to ensure distributed implementation as well as global convergence to the true coordinates.