(SOLVED) rotation of objects

I am getting my mind all garbled up on a seemingly very simple question.

Let's assume we have to points:

Vector3f p1 = new Vector3f(5,5,5);

Vector3f p2 = new Vector3f(0,5,5);

Now I have an object, let's say a long Cylinder:

Cylinder c = new Cylinder("cyl",16,16,3,15);

how do I make it such that the cylinder starts at p1 and ends at p2?

Because apparently, doing sth. like


places the center of the cylinder at p1, not one end of the cylinder.

Do I have to rotate it somehow? and where to translate to? I have no idea how to deal with Quaternions in order to rotate sth. being at point p1 for it to look at p2. Using the lookAt method results in a side of the cylinder looking at p2, not one end of it. Any help would be appreciated.

Make the Cylinder of a Size (1,1):

Cylinder c = new Cylinder("cyl", 16, 16, 1,1 );

Then the following code should do it:

Vector3f midPoint = p1.subtract(p2.mult(0.5f));
c.lookAt(p1, Vector3f.UNIT_Y);

PS: I'm not quite sure, if look At points the end to the given point or the side.

that doesn't work correctly, but it brought me back on track and this produces the desired results:

private Cylinder getLineSegment(Vector3f pos1, Vector3f pos2)


Vector3f mid = new Vector3f(Math.min(pos1.getX(), pos2.getX())+Math.abs(pos1.getX()-pos2.getX())/2,

Math.min(pos1.getY(), pos2.getY())+Math.abs(pos1.getY()-pos2.getY())/2,

Math.min(pos1.getZ(), pos2.getZ())+Math.abs(pos1.getZ()-pos2.getZ())/2);

Cylinder cyl = new Cylinder("cyl",2,8,0.1f,pos1.subtract(pos2).length());


cyl.lookAt(pos1, Vector3f.UNIT_Y);

return cyl;


Thanks for the help - much appreciated.