Hi,
Does anyone have an example of rotating vertices (as used when creating a b2PolyDef shape) ?
For example I have this triangle:
and here is a "house" shape:
How could I rotate each vertice in the examples above to any angle?
I thought it was something to do with sin() and cos() on the x/y values, but I'll be blown if I can get it working right!
Does anyone have an example of rotating vertices (as used when creating a b2PolyDef shape) ?
For example I have this triangle:
Code:
shapeDef.vertices[0].Set( -1, 0);
shapeDef.vertices[1].Set( 1, 0);
shapeDef.vertices[2].Set( 0, -2 );
shapeDef.vertices[1].Set( 1, 0);
shapeDef.vertices[2].Set( 0, -2 );
and here is a "house" shape:
Code:
shapeDef.vertices[0].Set( 1, 0 );
shapeDef.vertices[1].Set( -1, 0 );
shapeDef.vertices[2].Set( -1, -2 );
shapeDef.vertices[3].Set( 0, -3 );
shapeDef.vertices[4].Set( 1, -2 );
shapeDef.vertices[1].Set( -1, 0 );
shapeDef.vertices[2].Set( -1, -2 );
shapeDef.vertices[3].Set( 0, -3 );
shapeDef.vertices[4].Set( 1, -2 );
How could I rotate each vertice in the examples above to any angle?
I thought it was something to do with sin() and cos() on the x/y values, but I'll be blown if I can get it working right!