HotWheels
HotWheels

Reputation: 444

How to calculate screen coordinates after transformations?

I am trying to solve a question related to transformation of coordinates in 3-D space but not sure how to approach it.

Lets a vertex point named P is drawn at the origin with a 4x4 transformation matrix. It's then views through a camera that's positioned with a model view matrix and then through a simple projective transform matrix.

How do I calculate the new screen coordinates of P' (x,y,z)?

Upvotes: 2

Views: 2314

Answers (1)

Brian Choi
Brian Choi

Reputation: 753

Before explain of pipeline, you need to know is how pipeline do process to draw on screen. Everything between process is just matrix multiplication with vector

Model - World - Camera - Projection(or Nomalized Coordinate) - Screen

  1. First step, we call it 'Model Space' because of (0,0,0) is based in model.
  2. And we need to move model space to world space because of we are gonna place model to world so we need to do transform will be (translate, rotation, scale)TRS * Model(Vector4) because definition of world transform will be different After do it, model place in world.
  3. Thrid, need to render on camrea space because what we see is through the camera. in world, camera also has position, viewport size and rotation.. It needs to project from the camera. see

    After this job done, you will get nomalized coordinate which is Techinically 0-1 coordinates.

  4. Finaly, Screen space. suppose that we are gonna make vido game for mobile. mobile has a lot of screen resolution. so how to get it done? Simple, scale and translate to get result in screen space coordinate. Because of origin and screen size is different.

    So what you are tring to do is 'step 4'.

    1. If you want to get screen position P1 from world, formula will be "Screen Matrix * projection matrix * Camera matrix * P1"
    2. If you want to get position from camera space it would be "Screen Matrix * projection matrix * P1".

There are useful links to understand matrix and calculation so see above links.

Upvotes: 1

Related Questions