- 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.
推薦閱讀
- Learn TypeScript 3 by Building Web Applications
- Java面向?qū)ο筌浖_發(fā)
- PaaS程序設計
- OpenStack Cloud Computing Cookbook(Fourth Edition)
- Blockly創(chuàng)意趣味編程
- STM32F0實戰(zhàn):基于HAL庫開發(fā)
- OpenStack Orchestration
- Java:High-Performance Apps with Java 9
- 精通Python自動化編程
- C語言程序設計
- Python:Deeper Insights into Machine Learning
- Web App Testing Using Knockout.JS
- 一步一步跟我學Scratch3.0案例
- UML軟件建模
- Java多線程并發(fā)體系實戰(zhàn)(微課視頻版)