private void updatePositions(long elapsed)
    {
    	// calculate new speed
    	headSpeed += headAcceleration * (float)elapsed;

    	if (headSpeed < MIN_SPEED)
    		headSpeed = MIN_SPEED;
    	
    	// calculate change in position and update head position
    	Vector2D deltaPos = (direction).mult(headSpeed * (float)elapsed);
    	headPosition = headPosition.add(deltaPos);
    	
    	// check if direction has changed => push new segment
    	if (!direction.equals(segments.getFirst().norm().mult(-1.0f)))
    	{
    		segments.addFirst(new Vector2D(0, 0));
    	}
    	
    	// update the first segment
    	Vector2D newVec = segments.removeFirst().add(deltaPos.mult(-1.0f));
    	segments.addFirst(newVec);
    	
    	// calculate new tail speed
    	tailSpeed += tailAcceleration * elapsed;
    	
    	if (tailSpeed < MIN_SPEED)
    		tailSpeed = MIN_SPEED;
    	
    	// calculate distance to be covered by the tail
    	float deltaLength = tailSpeed * elapsed;
    	
    	// shorten and remove tail segments as necessary
    	Vector2D segment;
    	while (deltaLength > 0)
    	{
    		segment = segments.removeLast();
    		
    		// segment is shorter => delete
    		if (segment.magnitude() <= deltaLength)
    		{
    			deltaLength -= segment.magnitude();
    			
    			// was the last segment
    			if (segments.isEmpty())
    			{
    				isDead = true;
    				break;
    			}
    		}
    		else	// segment is longer => shrink
    		{
    			float newLength = segment.magnitude() - deltaLength;
    			segments.addLast(segment.norm().mult(newLength));
    			
    			deltaLength = 0;
    		}
    	}
    }