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

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.

主站蜘蛛池模板: 营山县| 永宁县| 攀枝花市| 扎兰屯市| 东乡县| 崇阳县| 长治县| 渭源县| 资中县| 宜黄县| 洛浦县| 绥宁县| 阿拉善右旗| 左云县| 和平县| 通州市| 萨迦县| 宁武县| 邯郸县| 阳朔县| 九龙城区| 额济纳旗| 怀安县| 和顺县| 呼和浩特市| 长乐市| 沈丘县| 桃江县| 饶平县| 马鞍山市| 竹山县| 许昌县| 礼泉县| 黔西县| 西宁市| 弥勒县| 汝州市| 定南县| 滕州市| 玉龙| 确山县|