I think this is a correct way to do it. at least it looks correct on the screen...

I am using the JOML library for the matrix math

Instead of calculating the distance, i just drew a line between the two points:

First i have a method to get the current matrix:

`public float[] getCurrentMatrix() { `

float[] matrix = new float[16];

glGetFloatv(GL_MODELVIEW_MATRIX, matrix);

return matrix;

}

then after i do the transformations, i save the matrix into "m1" and "m2"

and then i manually calculate the new points

` // firstPoint and secondPoint are the points in the objects i `

// i want to draw the line

Vector3f v1 = new Vector3f(firstPoint[0], firstPoint[1], firstPoint[2]);

Vector3f v2 = new Vector3f(secondPoint[0], secondPoint[1], secondPoint[2]);

// set the matrices for JOML to use

Matrix4f m1 = new Matrix4f();

m1.set(firstMatrix);

Matrix4f m2 = new Matrix4f();

m2.set(secondMatrix);

// calculate the positions of those points

// using the same transformations

Vector3f newPoint1 = m1.transformPosition(v1);

Vector3f newPoint2 = m2.transformPosition(v2);

// draw the line

glLineWidth(10f);

glColor3f(1.0f, 1.0f, 0.0f);

glBegin(GL_LINES);

glVertex3f(newPoint1.x, newPoint1.y, newPoint1.z);

glVertex3f(newPoint2.x, newPoint2.y, newPoint2.z);

glEnd();

i am sure once i re-learn all my linear algebra that i have not looked at for 15 years, there will be a more efficient way of doing this, but this does work for now.