C# Class RedBlueGames.Tools.Vector2Extensions

Extension methods to Vector2 class
Afficher le fichier Open project: redbluegames/rb-unity-tools

Méthodes publiques

Méthode Description
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))

Private Methods

Méthode Description
GetBisectorForArc ( this vector, int arc, int numArcs, float rotationDegrees = 0.0f ) : Vector2
GetNearestArc ( this vector, int numArcs, float rotationDegrees = 0.0f ) : int

Method Details

BiasToCardinals() public static méthode

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.
Résultat UnityEngine.Vector2

GetDegreesBetweenVectorsCCW() public static méthode

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
Résultat float

IsDirectionWithinArc() public static méthode

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
Résultat bool

IsNormalized() public static méthode

Determines if the vector is normalized (magnitude of 1)
public static IsNormalized ( this vector ) : bool
vector this Vector to test.
Résultat bool

RotateClockwiseByRadians() public static méthode

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
Résultat UnityEngine.Vector2

RoundToCardinals() public static méthode

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.
Résultat UnityEngine.Vector2

RoundToNearestArc() public static méthode

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
Résultat UnityEngine.Vector2