sajis997

02-04-2013, 01:46 PM

Hello forum,

I am getting with the following code snippet:

glm::vec2 points[NumPoints];

// Specifiy the vertices for a triangle

glm::vec2 vertices[3] =

{

glm::vec2( -1.0, -1.0 ), glm::vec2( 0.0, 1.0 ), glm::vec2( 1.0, -1.0 )

};

// Select an arbitrary initial point inside of the triangle

points[0] = glm::vec2( 0.25, 0.50 );

// compute and store N-1 new points

for ( int i = 1; i < NumPoints; ++i )

{

int j = rand() % 3; // pick a vertex at random

// Compute the point halfway between the selected vertex

// and the previous point

//GETTING COMILATION ERROR IN THE FOLLOWING LINE

points[i] = ( points[i - 1] + vertices[j] ) / 2.0;

}

The error says there is matching operator.

Any idea to get around the problem?

Regards

Sajjad

I am getting with the following code snippet:

glm::vec2 points[NumPoints];

// Specifiy the vertices for a triangle

glm::vec2 vertices[3] =

{

glm::vec2( -1.0, -1.0 ), glm::vec2( 0.0, 1.0 ), glm::vec2( 1.0, -1.0 )

};

// Select an arbitrary initial point inside of the triangle

points[0] = glm::vec2( 0.25, 0.50 );

// compute and store N-1 new points

for ( int i = 1; i < NumPoints; ++i )

{

int j = rand() % 3; // pick a vertex at random

// Compute the point halfway between the selected vertex

// and the previous point

//GETTING COMILATION ERROR IN THE FOLLOWING LINE

points[i] = ( points[i - 1] + vertices[j] ) / 2.0;

}

The error says there is matching operator.

Any idea to get around the problem?

Regards

Sajjad