Chapter 4 (4th edition) MSL Math Constants

Hi. In the Challenge section of chapter 4, page 86 there is the comment:

Notice that there’s no built in value for pi on the GPU.

But MSL defines several mathematical constants, This works:
position.x = radius * cos(2 * M_PI_F * current);
position.y = radius * sin(2 * M_PI_F * current);

3 Likes

Excellent. Thank you very much for pointing this out.

2 Likes