C# Класс RedBlueGames.Tools.Vector2Extensions

Extension methods to Vector2 class
Показать файл Открыть проект

Открытые методы

Метод Описание
BiasToCardinals ( this vectorToBias, float biasAngle ) : Vector2

If the supplied vector is within the supplied angle of a cardinal direction, this will return the cardinal direction. Otherwise it will just return the same angle.

GetDegreesBetweenVectorsCCW ( Vector2 fromVector, Vector2 toVector ) : float

Returns the angle in degrees from one Vector2 to another. Degrees are signed, with CCW being positive.

IsDirectionWithinArc ( this vector, Vector2 arcBisector, float arcAngle ) : bool

Determines if the direction vector is within the arc specified by a direction bisecting an angle.

IsNormalized ( this vector ) : bool

Determines if the vector is normalized (magnitude of 1)

RotateClockwiseByRadians ( this vector, float angle ) : Vector2

Rotates the vector clockwise by an angle in radius

RoundToCardinals ( this vectorToRound ) : Vector2

Rounds the input vector to the closest cardinal direction and returns the rounded result.

RoundToNearestArc ( this vector, int numArcs, float rotationDegrees = 0.0f ) : Vector2

Rounds to nearest arc (with 4 arcs, all vectors that point from -45 to 45 return (1.0, 0.0))

Приватные методы

Метод Описание
GetBisectorForArc ( this vector, int arc, int numArcs, float rotationDegrees = 0.0f ) : Vector2
GetNearestArc ( this vector, int numArcs, float rotationDegrees = 0.0f ) : int

Описание методов

BiasToCardinals() публичный статический Метод

If the supplied vector is within the supplied angle of a cardinal direction, this will return the cardinal direction. Otherwise it will just return the same angle.
public static BiasToCardinals ( this vectorToBias, float biasAngle ) : Vector2
vectorToBias this Vector to bias.
biasAngle float Bias angle.
Результат UnityEngine.Vector2

GetDegreesBetweenVectorsCCW() публичный статический Метод

Returns the angle in degrees from one Vector2 to another. Degrees are signed, with CCW being positive.
public static GetDegreesBetweenVectorsCCW ( Vector2 fromVector, Vector2 toVector ) : float
fromVector UnityEngine.Vector2 The from vector
toVector UnityEngine.Vector2 The to vector
Результат float

IsDirectionWithinArc() публичный статический Метод

Determines if the direction vector is within the arc specified by a direction bisecting an angle.
public static IsDirectionWithinArc ( this vector, Vector2 arcBisector, float arcAngle ) : bool
vector this Source Direction Vector
arcBisector UnityEngine.Vector2 Arc bisector
arcAngle float Arc angle
Результат bool

IsNormalized() публичный статический Метод

Determines if the vector is normalized (magnitude of 1)
public static IsNormalized ( this vector ) : bool
vector this Vector to test.
Результат bool

RotateClockwiseByRadians() публичный статический Метод

Rotates the vector clockwise by an angle in radius
public static RotateClockwiseByRadians ( this vector, float angle ) : Vector2
vector this Vector to rotate.
angle float Angle in radians
Результат UnityEngine.Vector2

RoundToCardinals() публичный статический Метод

Rounds the input vector to the closest cardinal direction and returns the rounded result.
public static RoundToCardinals ( this vectorToRound ) : Vector2
vectorToRound this Vector to round.
Результат UnityEngine.Vector2

RoundToNearestArc() публичный статический Метод

Rounds to nearest arc (with 4 arcs, all vectors that point from -45 to 45 return (1.0, 0.0))
public static RoundToNearestArc ( this vector, int numArcs, float rotationDegrees = 0.0f ) : Vector2
vector this The vector to convert.
numArcs int The number of arcs to divide the circle into.
rotationDegrees float Optional rotation of arcs
Результат UnityEngine.Vector2