In Act III, Scene i of Hamlet, Claudius and Polonius have decided to spy on Hamlet. They set a scene so that they can, unobserved, see and hear his conversation with Ophelia. Hamlet gives his famous "To be or not to be" speech, then proceeds to insult Ophelia, calling her an ugly whore.
After he exits, Polonius and Claudius reveal themselves. Claudius believes that Hamlet is not in love, but that he is also not mad. Instead, he thinks that there is something secret that is bothering Hamlet and thereby affecting his behavior. Polonius, however, still is convinced that Hamlet is in love, and rationalizes his anger and insults by saying that they spring from neglected love for Ophelia.
As a result of their plan, Claudius and Polonius determine that Hamlet must be at once sent away to England.