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

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.

主站蜘蛛池模板: 富川| 项城市| 聂拉木县| 荔波县| 柏乡县| 农安县| 甘孜| 台南县| 灵川县| 东莞市| 遂川县| 连江县| 政和县| 忻城县| 乐安县| 章丘市| 肇东市| 报价| 读书| 邻水| 阜新市| 沭阳县| 青海省| 兴业县| 刚察县| 合肥市| 玛多县| 吉林省| 湖南省| 鸡泽县| 万源市| 黔南| 南和县| 扶余县| 东台市| 樟树市| 新乡县| 葫芦岛市| 嵊州市| 郁南县| 峨眉山市|