Get position relative to spatials direction (math ?)

I have an arbitrary point (vector3f) that I’m rotating around a spatial. I have the rotation formula but I need to figure out if I’m on the left/right side or ahead/behind the spatial in relation to it’s current direction.

In this case the Y position is irrelevant. It doesn’t matter how far above or below the point is only that it is behind the object on the X/Z axis. I know the spatials direction (2nd rotation column) and my points location I’m just not sure where to go from there.

What I’m doing is orbiting a point around a moving spatial. If the point goes to far to the left or right of the spatial I want to rotate it so it’s directly behind the spatial. I just can’t figure out what side I’m on either left/right or ahead/behind. It’s more important that I know the left/right I can do without the ahead/behind.

Before anyone makes the suggestion , I’m not using nodes for this and I’m not going too. I just need some help with the math.


Vector3f someWorldPoint =....
Vector3f objectLocWorld = ...
Quaternion objectRotation = ...

Vector3f left = objectRotation.mult(Vector3f.UNIT_X);
Vector3f relative = someWorldPoint.subtract(objectLocWorld);
float dot =;

If dot is positive then the object is somewhere to the left. If it’s negative then it’s somewhere to the right. 1 is directly left, -1 is directly right.

Vector3f look = objectRotation.mult(Vector3f.UNIT_Z);
float dot2 =

…will do the same for front and back.

Edit: actually you have to normalize relative if you want ‘dot’ to be between 0 to 1. Forgot that part. Else dot() will give you the cosine of the angle between ‘relative’ and left multiplied by the length of ‘relative’.