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

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.

主站蜘蛛池模板: 澄城县| 杂多县| 肇东市| 靖州| 康保县| 东港市| 牙克石市| 田东县| 利津县| 昌图县| 越西县| 孝昌县| 图片| 罗山县| 密云县| 萨嘎县| 赞皇县| 南平市| 灌云县| 九龙城区| 延津县| 邵阳市| 磴口县| 洛阳市| 宿迁市| 岑巩县| 晋城| 阳城县| 黄平县| 连城县| 镇远县| 大冶市| 阿拉善左旗| 敦化市| 理塘县| 镇雄县| 涞源县| 信阳市| 临沭县| 广东省| 湟源县|