hypot is not supported in every compiler so replaced with explicit code version