Why do you need to name your class fields as c, cc, d, e? What the hell are you trying to obfuscate? And no, that wall of well-aligned comments is not a solution. And please, stop teaching students variables by naming them a, b, c, d. Please. Just. Stop. Later they become professors who can not produce a readable code.
You probably think that your code looks good because it nicely fits in a box. I know that you were making pixel shaders before I was even born, but you are wrong.
/** A two dimensional array holding particle positions. For the * derived container_poly class, this also holds particle * radii. */ double **p;
Why don't you just name it "positions"? What are you trying to save? Certainly not a compiled binary size, because the name does not matter there. Are you producing that extremely complicated code inside this class SO FAST that you can not type a full name of "positions" variable every time it is needed? No wonder you end up with your method contents looking like this:
int l,dijk=di+nx*(dj+oy*dk),dijkl,dijkr,ima=step_div(dk-ez,nz); int qj=dj+step_int(-ima*byz*ysp),qjdiv=step_div(qj-ey,ny); int qi=di+step_int((-ima*bxz-qjdiv*bxy)*xsp),qidiv=step_div(qi,nx); int fi=qi-qidiv*nx,fj=qj-qjdiv*ny,fijk=fi+nx*(fj+oy*(dk-ima*nz)),fijk2; double disy=ima*byz+qjdiv*by,switchy=(dj-ey)*boxy-ima*byz-qjdiv*by; double disx=ima*bxz+qjdiv*bxy+qidiv*bx,switchx=di*boxx-ima*bxz-qjdiv*bxy-qidiv*bx; double switchx2,disxl,disxr,disx2,disxr2; /* so you have created qj, qi, and more badly named crap at the top of your function... again. */
Oh sure it is more compact. And that is NOT a good thing. Of COURSE I can figure out what it all means eventually, I am not THAT stupid. But it is not the point.
What if you have another friggin' class where "p" means "pizza"? Why do you have to remember to mentally switch from "oh, I am working with particle class so "p" means "positions"" to "oh this is pizza delivery class so "p" means "pizza"".
But yeah, I understand that you won't encounter "pizza" anywhere, because you have never worked with a huge code base where you simply can not remember everything.
P.S. This little rant was not intended as a good critique. It just sometimes gets to me
Edited by Nercury, 13 April 2013 - 09:11 AM.