官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 克拉玛依市| 嘉荫县| 六安市| 九龙坡区| 泗水县| 高平市| 甘德县| 微山县| 永善县| 承德市| 广水市| 阜新| 金湖县| 衡南县| 澄江县| 清原| 本溪市| 和田市| 宜兰县| 堆龙德庆县| 奉化市| 郧西县| 泰和县| 寿宁县| 黄石市| 萨嘎县| 中西区| 高州市| 古田县| 栾城县| 丹东市| 越西县| 探索| 开阳县| 安吉县| 乐都县| 崇阳县| 微博| 九龙县| 五峰| 景宁|