Control and Estimation of Piecewise Affine Systems