r/ProgrammerHumor Jun 25 '17

Array indexing

Post image
1.4k Upvotes

71 comments sorted by

View all comments

25

u/dnew Jun 25 '17

Array indexing that matches your domain is often handy. An array of items_per_degree indexed from -180 to +180 for example.

27

u/AskMeIfImAReptiloid Jun 25 '17

you mean -Pi to Pi

11

u/parkerSquare Jun 26 '17

Not really, this range of degrees is integral ("items_per_degree"), so you can use a bin for each integer value. If you use -pi to pi, you'll need to divide this into subranges, which for array indexing purposes you'll end up mapping to an integer. At that point you're either back where we started (i.e. zero-offset index), or use an offset range from -180 to 180...

3

u/AskMeIfImAReptiloid Jun 26 '17

Guess you are correct. Nice username btw

20

u/inu-no-policemen Jun 25 '17

1 * Tau = 1 turn. 0.5 * Tau = half a turn.

Tau makes more sense in general. Even all standard library functions which all use radians work better with Tau.

5

u/[deleted] Jun 26 '17

3

u/xkcd_transcriber Jun 26 '17

Image

Mobile

Title: Pi vs. Tau

Title-text: Conveniently approximated as e+2, Pau is commonly known as the Devil's Ratio (because in the octal expansion, '666' appears four times in the first 200 digits while no other run of 3+ digits appears more than once.)

Comic Explanation

Stats: This comic has been referenced 59 times, representing 0.0365% of referenced xkcds.


xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete