Camera tips for Unity3d technology-the size of the cones from the camera to a given distance

Source: Internet
Author: User

Welcome to Unity Learning, unity training, Unity Enterprise training and education zone, there are many u3d resources, u3d training videos, u3d tutorials, U3d Frequently asked questions, U3d Project source code, we are committed to creating the industry Unity3d training, learning the first brand.

The size of the cones from the camera to a given distance

The View cone cross-section from the camera to a certain distance is defined as a rectangle in world space, including the visible area box. Sometimes this is useful for calculating the size of the rectangle at a given distance, or for finding the size of a given rectangle. For example, if a moving camera needs to always take a full shot of an object (such as a player), it cannot get too close, or part of the object cannot be snapped.

The height of the cones at a given distance (the units of both are world units) can be obtained by the following formula:-

var frustumheight = 2.0 * Distance * Mathf.tan (Camera.fieldofview * 0.5 * Mathf.deg2rad);

...... The process can be reversed to calculate the desired distance to obtain the specified cone height:-

var distance = Frustumheight * 0.5/mathf.tan (Camera.fieldofview * 0.5 * Mathf.deg2rad);

The calculated FOV angle is also possible with the known height and distance:-

var Camera.fieldofview = 2 * Mathf.atan (Frustumheight * 0.5/distance) * MATHF.RAD2DEG;

Each formula contains a cone height, which can be easily obtained by width (and vice versa):-

var frustumwidth = frustumheight * camera.aspect;
var frustumheight = Frustumwidth/camera.aspect;

For more highlights, please click http://www.gopedu.com/

Camera tips for Unity3d technology-the size of the cones from the camera to a given distance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.