you feel bad at that kind of hacky code, right. but then you look at like, the source code for some million-unit-selling game, and it's full of the same kind of thing, only they write it in a fancy way using a bunch of vector operations with comments like
// transform object into milkspace
// skim precomputed full-fat coefficients (defined in milk_constants.h)
// perform milkspace alignment and project from milkspace back into spacespace