I have a polygon class, and in order to incorporate roation into it, I wanted to generate cosine and sine lookup tables, as my book suggests:

Code:

void _POLYGON2D::GenerateTables()
{
for (int ang = 0;ang<360;ang++)
{
float theta = static_cast<float>(ang*3.14159/180);
cos_look[ang] = cos(theta);
sin_look[ang] = sin(theta);
}
}

(cos_look and sin_look are float arrays within the class)

Of course this doesn't seem like a good way, since I want to create polygons using some sort of linked list, i would have to call this function every time I added a new one...Could I declare cos_look and sin_look static like this:

Code:

typedef _POLYGON2D
{
public:
//...
void GenerateTables();
//...
private:
static float sin_look[360];
static float cos_look[360];
} Polygon2D, *PtrPolygon2D;

If my understanding is correct, declaring members static gives the the same values throughout all instances of the class, so could I just call GenerateTables() once like this:

Code:

//in initialization function
Polygon2D::GenerateTables();

And then have the arrays be initialized for all my polygon objects?