Attributes
struct FVector2D
{
/** Vector's X component. */
float X;
/** Vector's Y component. */
float Y;
}
2D vector, two members of float x, y, very simple.
method
Are some of the basic operations.
向量加法
FORCEINLINE FVector2D operator+(const FVector2D& V) const;
向量减法
FORCEINLINE FVector2D operator-(const FVector2D& V) const;
数乘/除
FORCEINLINE FVector2D operator*(float Scale) const;
FVector2D operator/(float Scale) const;
向量分量+/-/*//同一个数
FORCEINLINE FVector2D operator+(float A) const;
FORCEINLINE FVector2D operator-(float A) const;
FORCEINLINE FVector2D operator*(float Scale) const;
FVector2D operator/(float Scale) const;
向量分量*//
FORCEINLINE FVector2D operator*(const FVector2D& V) const;
FVector2D operator/(const FVector2D& V) const;
向量点乘
FORCEINLINE float operator|(const FVector2D& V) const;
向量叉乘(注意结果是一个值)
FORCEINLINE float operator^(const FVector2D& V) const;
……………………………………………………………………………………………………………………………………………………………………………………………………
FVector2D GetRotated(float AngleDeg) const;
Detour calculation point vector rotated counterclockwise vector, using the vector rotation matrix calculation of multiplying. A two-dimensional rotation matrix is: $$ \ left [\ begin {matrix} cos \ theta & sin \ theta \\ -sin \ theta & cos \ theta \ end {matrix} \ right] $$
计算单位向量,零向量返回零向量
FVector2D GetSafeNormal(float Tolerance=SMALL_NUMBER) const;
向量单位化
void Normalize(float Tolerance=SMALL_NUMBER);
void ToDirectionAndLength(FVector2D &OutDir, float &OutLength) const;
Obtain the vector length and direction vector
FVector2D RoundToVector() const;
round to the nearest whole point
inline FVector SphericalToUnitCartesian() const;
This function means that the 2D vector used to represent a 3D vector in the form of spherical coordinates, the vector in the unit above the end of the ball, x denotes θ, y represents φ, r 1 is implied, and returns the form of a vector of Cartesian coordinates, in fact, spherical coordinate to a Cartesian coordinate, strange form just above.
- x = rsinθcosφ = sinxcosy
- y = rsinθsinφ = sinxsiny
- z = rcosθ = cosx