Projecting a 3D point to a 2D screen coordinate

后端 未结 6 552
难免孤独
难免孤独 2020-12-08 18:06

Based on information in Chapter 7 of 3D Programming For Windows (Charles Petzold), I\'ve attempted to write as helper function that projects a Point3D to a standard 2D Point

6条回答
  •  半阙折子戏
    2020-12-08 18:34

    1. It's not clear what you are trying to achieve with aspectRatio coeff. If the point is on the edge of field of view, then it should be on the edge of screen, but if aspectRatio!=1 it isn't. Try setting aspectRatio=1 and make window square. Are the coordinates still incorrect?

    2. ActualWidth and ActualHeight seem to be half of the window size really, so screenX will be [-ActualWidth; ActualWidth], but not [0; ActualWidth]. Is that what you want?

提交回复
热议问题