implement perfect elastic collision