I'm working on some 3D graphics software that requires a draw loop to access a large number of vertices many times. For each vertex component I need to access the following information:
On each time through the draw loop, I need the transformed value of the vertex (for example: transformedX = vertex_originalvalue_x + vertex_transform_x).
My question is whether it is better to store a separate variable in which the transformation computation has already been performed or whether it should be done on the fly.
Does anyone have some rules of thumb for which mathematical operations make things costly enough that storing a precomputed value is worthwhile? Perhaps a single addition operation is quick enough, but if something like a square root operation were required, would it then makes sense to precompute and store?
Thanks. Any advice, opinion, debate on this issue is welcomed.