how to rotation a line to another line?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
hzsyber
Posts: 52
Joined: Tue Apr 01, 2008 2:21 pm
Location: Canton,China.

how to rotation a line to another line?

Post by hzsyber »

i have a problem, how to rotation a line to another line.
line a(x,y,z) b(x-10,y,z) parallel on axis X.
point c(0,0,0).

i need line ab rotation around point a to line bc.
photo:
Image
i try code:

Code: Select all

void rotateVectorAroundAxis(vector3df& vector, const vector3df& axis, f32 radians)
{
   quaternion MrQuaternion;
   matrix4 MrMatrix;
   (void)MrQuaternion.fromAngleAxis(radians, axis);
   MrQuaternion.getMatrix(MrMatrix);
   MrMatrix.rotateVect(vector);
}

vector3df CenterAxisRotation(vector3df a, vector3df b, vector3df c)
{
	vector3df linea = (b - a);
	vector3df lineb = (c - a);
	vector3df cp = linea.crossProduct(lineb);
	f32 radians = acos(a / sqrt(pow(a.x,2)+pow(a.y,2)+pow(a.z,2)));
	vector3df ResRot = a;
	rotateVectorAroundAxis(ResRot, cp, radians);
	return ResRot;
}
but it no work.why?how to do?

thanks all!
hzsyber
Posts: 52
Joined: Tue Apr 01, 2008 2:21 pm
Location: Canton,China.

Post by hzsyber »

help please.
hzsyber
Posts: 52
Joined: Tue Apr 01, 2008 2:21 pm
Location: Canton,China.

Post by hzsyber »

why nobody answer me?
Post Reply