brett01

09-13-2009, 04:35 PM

hi,

I am having a problem with a simple rotation problem.I have attached a rectangle to a coordinate axes such that one of its vertices align with the origin.I want to translate rectangle center to the origin and rotate the rectangle with respect to the current center.

In init() I translated rectangle's center to origin.Now I need to rotate it in run(). what Ive done is

init()

{

translate(T);

scale(s);

rectangle();

}

in run()

{

gltranslate(-T)

rotate(x,1,0,0);

gltranslate(t);

}

The problem is the rectangle is always rotating wrt to the vertex but not the center of the rectangle.what is the problem with my code??Can someone help me please.

Thank you.

I am having a problem with a simple rotation problem.I have attached a rectangle to a coordinate axes such that one of its vertices align with the origin.I want to translate rectangle center to the origin and rotate the rectangle with respect to the current center.

In init() I translated rectangle's center to origin.Now I need to rotate it in run(). what Ive done is

init()

{

translate(T);

scale(s);

rectangle();

}

in run()

{

gltranslate(-T)

rotate(x,1,0,0);

gltranslate(t);

}

The problem is the rectangle is always rotating wrt to the vertex but not the center of the rectangle.what is the problem with my code??Can someone help me please.

Thank you.