 
 	_sectionStartingIndex: (section) ->
 		result=0
-		for idx in [0...@_sections.indexOf(section)] 
+		for idx in [0...@_sections.indexOf(section)]
 			do (idx) =>
 				result+=@_sections[idx]._pieces.length
 		result


class Split extends Piece
	setSection: (section) ->
		@connections.B = new Connection(@size*section.track.gridSize, 0, 0)
		@connections.C = new Connection(
			Math.sin(@angle)*section.track.gridSize,
			@flip*(1-Math.cos(@angle))*section.track.gridSize,
			@flip*@angle*180/Math.PI)


class Crossover extends Piece
	setSection: (section) ->
		@connections.B = new ConnectedTransform(
			Math.sin(@angle)*section.track.gridSize,
			@flip*(1-Math.cos(@angle))*section.track.gridSize,
			@flip*@angle*180/Math.PI)
		@connections.C = new ConnectedTransform(
			2*section.track.gridSize*Math.sin(@angle/2),
			@flip*2*section.track.gridSize*(1-Math.cos(@angle/2)),
			0)
		@connections.D = new ConnectedTransform(
			section.track.gridSize*(2*Math.sin(@angle/2)-Math.sin(@angle)),
			@flip*section.track.gridSize*(1-(2*Math.cos(@angle/2))+Math.cos(@angle)),
			@flip*((@angle*180/Math.PI)-180))
