(chapter III) UNITY3D-VECTOR3

Source: Internet
Author: User

Let's introduce the Vector3 class today.

Vector3 three-dimensional vector

Represents vectors and points for 3D.

This structure is used to deliver 3D positions and orientations in unity. It also contains functions that do ordinary vector operations.

In addition to the functions listed below, other classes are used to manipulate vectors and points. For example, the quaternion and matrix4x4 classes are used to rotate or transform vectors and points.


variables Variablex component of the x vector. Y component of the Y-vector. Z component of the z-vector. This [int index] uses [0], [1], [2] to access component X, Y, and z components respectively. In simple terms, the index number is used instead of the x, Y, and Z components. The length of the normalized return vector is 1 (read-only). Magnitude returns the length of the vector (read-only). Sqrmagnitude returns the square of the length of this vector (read-only).Constructors ConstructorsVector3 creates a new vector with the given x, Y, and Z components.functions FunctionThe scale is scaled by the same component that corresponds to each component of the vector. Normalize the length of the vector to 1. ToString returns a string formatted with this vector.Class variables VariablesZero writes Vector3 (0, 0, 0) of the simple code. One writes Vector3 (1, 1, 1) of the Jane Code. Forward writes the simple code of VECTOR3 (0, 0, 1), that is, to the z axis. Up writes Vector3 (0, 1, 0) of the simple code, that is, to the Y axis. Right Write Vector3 (1, 0, 0) of the simple code, that is, to the x-axis.class functions functionLerp a linear interpolation between two vectors. Slerp the spherical interpolation between the two vectors. The orthonormalize normalize the vectors and are perpendicular to each other. Movetowards the current location to the target. Rotatetowards the current vector to the target. Smoothdamp gradually changes a vector toward the desired target over time. Scale two vector components correspond to multiply. The cross product of two vectors. Returns the LHS x RHS Reflect along the normal reflection vector. Dot two The dot product of a vector. Project projects a vector to another vector. Angle returns an angle from both from and to. Distance returns the distance between A and B. Clampmagnitude returns the length of the vector, not exceeding the length indicated by MaxLength. Min Returns a vector consisting of the smallest components of two vectors. Max returns a vector consisting of the largest components of two vectors. operator + Two vectors added. operator-one vector minus another vector. operator * consists of a number multiplied by a vector. operator/divide a vector by a number. i.e. A/b. operator = = Returns true if two vectors are equal. Operator! = Returns true if the vectors are different.


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.