In this study, we numerically investigate the terahertz radiation from mesa-structured intrinsic Josephson junctions (IJJs) using a three-dimensional calculation model. We assume an in-phase mode of the phase differences and calculate electromagnetic fields inside and outside of the IJJs simultaneously. We consider the appearance of a hot spot in the mesa where j c locally decreases and investigate the change of the radiation power with varying hot-spot positions. The radiation powers for three different hot-spot positions are calculated as functions of voltage. We observe strong radiation when the ac Josephson frequency satisfies the cavity resonance condition. Transverse-magnetic modes TM m,n whose indices m and n are even appear regardless of the positions of hot spots. Meanwhile, the TM m,n cavity modes whose m or n are odd appear only when the hot spots break the reflectional symmetry of the mesa structure. Moreover, we calculate the radiation patterns emitted by the IJJs at these cavity resonance conditions. The radiation patterns reflect the existence of two types of internal modes, that is, a uniform background mode and a cavity resonance mode.