- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 120字
- 2021-06-30 14:46:00
Perspective
A perspective matrix is built from a field of view (typically in degrees), an aspect ratio, and near and far distances. It serves as an easy way to create a view frustum.
Implement the perspective function in mat4.cpp. Don't forget to add the function declaration to mat4.h:
mat4 perspective(float fov, float aspect, float n,float f){
float ymax = n * tanf(fov * 3.14159265359f / 360.0f);
float xmax = ymax * aspect;
return frustum(-xmax, xmax, -ymax, ymax, n, f);
}
The perspective function will be used in almost all visual graphics demonstrations throughout the rest of this book. It's a really convenient way of creating a view frustum.
推薦閱讀
- GeoServer Cookbook
- Android開發精要
- 實戰Java程序設計
- C#程序設計(慕課版)
- 數據庫系統原理及MySQL應用教程
- Architecting the Industrial Internet
- Git高手之路
- 深度強化學習算法與實踐:基于PyTorch的實現
- Apache Mesos Essentials
- Apache Mahout Clustering Designs
- UNIX Linux程序設計教程
- PrimeFaces Blueprints
- Ext JS 4 Plugin and Extension Development
- 軟件工程與UML案例解析(第三版)
- Clojure High Performance Programming(Second Edition)