Skip to main content
1 of 2
zoul
  • 178
  • 5
  • Why the #ifdef guard? It’s not needed in Objective-C since we have the #import directive instead of #include.

  • Why have the whole thing in the header? The usual solution is to put the function declarations into the header and the implementations into the implementation file.

  • The difference between PolarEqualToPolar and PolarIdenticalToPolar is not clear to me. I mean, I could assert something from the implementation, but that’s not a good API if I have to.

  • Related to the previous point, do you realize you’re skating on thin ice when comparing the float components using plain equality (==)? The same disclaimer applies here as for any floating-point comparison, there are nasty suprises caused by precision issues. (See the classical article about What Every Computer Scientist Should Know About Floating-Point Arithmetic.) This is not necessarily a fault of your API or code, it’s just good to be aware of.

  • Do you really need the performance gains to write this in C instead of Objective-C? Always use high-level code unless the profiler tells you otherwise. Granted, polar coordinates are somewhat on the performant side, but then the modern hardware is so fast you could write the code in high-level Objective-C and still get very usable performance for most use cases.

zoul
  • 178
  • 5