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

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.

主站蜘蛛池模板: 永定县| 韩城市| 丰顺县| 伊宁市| 渝北区| 娱乐| 博兴县| 张北县| 巴中市| 大丰市| 尼勒克县| 嘉善县| 韩城市| 普洱| 驻马店市| 洪雅县| 乌什县| 四会市| 南漳县| 长武县| 纳雍县| 遂川县| 久治县| 永昌县| 滦南县| 布尔津县| 多伦县| 五寨县| 元江| 盈江县| 新竹市| 望城县| 青州市| 松江区| 马鞍山市| 紫云| 静安区| 华池县| 青神县| 太湖县| 青龙|