# How to get a camera view of 2 points such that they are overlapping

Hello,

I have 2 Cartesian3 points A and B. I want to place a camera near A, looking at A, such that “camera - A - B” are in a line. That means view will be such that A is overlapping B.
How this will be achieved?

Thanks

Hello,

If I understand you correctly, you want to place the camera on a line containing both A and B, with A between B and the camera. An easy way to compute camera location in this case would be to use a ray. By subtracting position B from position A, you can get the direction vector pointing from B to A, once you have this direction vector, you can create a ray with A as its origin, then compute a new camera position by moving along the ray by some offset distance. You can use the Cesium Ray to create a ray then compute a point along it. http://cesiumjs.org/Cesium/Build/Documentation/Ray.html?classFilter=ray

The pseudo code would look something like this.

vector3 direction = normalize(A - B);

vector3 origin = A;

Ray new_ray = Ray(A, direction);

vector3 new_camera_pos = Cesium.Ray.getPoint(new_ray, offset_distance);

Hope that helps! Let me know if this is confusing – I can write a more thorough code example.

Cheers,

• Rachel