How can I detect if a portion of an object has come in contact with or is inside of another object. Like a square or triangle or circle shaped object entering another shape.

Just explain theory, don't give me lines upon lines of code.