# How can I convert the vertices from world coordinates to frustum coordinates?

Hi!

I tried to convert the vertices from world coordinates to frustum coordinates by doing this in AbstractCamera:

```public Vector3f getFrustumCoordinates( Vector3f worldPosition, Vector3f store ) {         if ( store == null ) {             store = new Vector3f();         }         checkViewProjection();         tmp_quat.set( worldPosition.x, worldPosition.y, worldPosition.z, 1 );         modelViewProjection.mult( tmp_quat, tmp_quat );         tmp_quat.multLocal( 1.0f / tmp_quat.w );         store.x = tmp_quat.x;         store.y = tmp_quat.y;         store.z = tmp_quat.z;         return store;     }```

In my case, frustumLeft = -0.1, frustumRight = 0.1, viewportLeft = 0 and viewportRight = 1. When I call this method on vertices that are inside the view frustum, I should get some abscissa between -0.1 and 0.1, shouldn't I? Why do I get abscissa between -1 and 1 instead?

* @author Mark Powell
* @author Joshua Slack

I have found the answer alone and I'm going to explain to you what I understand as it might help anyone here one day. The source code below inspired me to write my method:

```public Vector3f getScreenCoordinates( Vector3f worldPosition, Vector3f store ) {         if ( store == null ) {             store = new Vector3f();         }         checkViewProjection();         tmp_quat.set( worldPosition.x, worldPosition.y, worldPosition.z, 1 );         modelViewProjection.mult( tmp_quat, tmp_quat );         tmp_quat.multLocal( 1.0f / tmp_quat.w );         store.x = ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 ) * getWidth();         store.y = ( ( tmp_quat.y + 1 ) * ( viewPortTop - viewPortBottom ) / 2 ) * getHeight();         store.z = ( tmp_quat.z + 1 ) / 2;         return store;     }```

The author does ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 ) in order to go from the normalized device coordinates to window coordinates. The normalized device coordinates go from -1 to 1 (if the vertex is inside the window). +1 allows to go from 0 and 2. By default, multiplying by ( viewPortRight - viewPortLeft ) / 2 allows to go from 0 and 1. The last step allows to go from 0 and "width".

Then I have to do:

`store.x = ( ( ( tmp_quat.x + 1 ) * ( frustumRight - frustumLeft ) / 2 ) ) + frustumLeft;`

:D

Finally, I don't understand why we don't do "+ viewPortLeft" in the method getScreenCoordinates(...).