In-wheel direct drive motors are placed inside drive wheels of electric vehicles and have to deliver large torque without any mechanical gear. Most often these machines are of synchronous type with permanent magnets and large pole-pair number. As a consequence of high peak torque, both cogging torque and torque ripple are increased if no measures are taken to decrease them. The vibrations due to cogging torque and torque ripple result in noise and reduced motor durability. In this paper, analytical equations and finite element method are derived, developed and used in order to analyse the dependence of cogging torque on magnet shape and size. A novel magnet shape is found that eliminates cogging torque without reducing the motor torque constant or increasing magnet size. The shape is applicable to any surface mounted permanent magnet motor with high number of pole pairs.