Transannular reactions of cycloalkenes, cycloalkadienes, and cycloalkatrienes. 17. N-Heterocyclization in electrophilic haloamidation reactions of 1,5-cyclooctadiene. Synthesis and rearrangements of the granatanine and homonortropane skeletons