C# Class Ensage.Common.Extensions.VectorExtensions

Extension class for Vector2, Vector3 and Vector4 classes of SharpDX.
Datei anzeigen Open project: EnsageSharp/Ensage.Common Class Usage Examples

Public Methods

Method Description
Distance ( this v1, System.Vector2 v2 ) : float

Extension wrapper for Vector2.Distance method

Distance ( this v1, System.Vector3 v2 ) : float

Extension wrapper for Vector3.Distance method

Distance ( this v1, System.Vector4 v2 ) : float

Extension wrapper for Vector4.Distance method

Distance2D ( this vector, System.Entity unit ) : float

Extension wrapper for Vector2.Distance method, to calculate distance between a vector and a unit

Distance2D ( this v1, System.Vector3 v2 ) : float

Extension wrapper for Vector2.Distance method

Distance2D ( this v1, System.Vector4 v2 ) : float

Extension wrapper for Vector2.Distance method

Distance3D ( this v1, System.Vector4 v2 ) : float

Extension wrapper for Vector3.Distance method

FindAngleBetween ( this first, System.Entity unit, bool radian = false ) : float

Calculates the angle between a vector and a unit. The angle represents at which direction the unit resides in compared to vector. Returns degree values on default, radian if requested.

FindAngleBetween ( this first, System.Vector2 second, bool radian = false ) : float

Calculates the angle between two vectors. The angle represents at which direction the second vector resides in compared to first vector. Returns degree values on default, radian if requested.

FromPolarAngle ( float polar ) : System.Vector2

Constructs a Unit Vector2 from polar angle

FromPolarCoordinates ( float radial, float polar ) : System.Vector2

Constructs a Vector2 from polar coordinates.

IsValid ( this v ) : bool

Returns true if the vector is valid.

PolarAngle ( this vector, bool radian = false ) : float

Calculates the polar angle of the given vector. Returns degree values on default, radian if requested.

Rotate ( this vector, float delta ) : System.Vector2

Rotates the given vector by given angle relative to zero vector.

Rotate ( this vector, float delta, System.Vector2 origin ) : System.Vector2

Rotates the given vector by given angle relative to given origin

SwitchYZ ( this v ) : System.Vector3

ToVector2 ( this vector ) : System.Vector2

Converts the given Vector3 to a Vector2. Disregards Z property.

ToVector3 ( this vector ) : System.Vector3

Converts the given Vector4 to a Vector3. Disregards W property.

ToVector3 ( this vector, bool ground = false ) : System.Vector3

Converts the Vector2 to Vector3. Populates the Z property of the returned value with ground data if requested.

ToVector4 ( this vector ) : System.Vector4

Converts the given Vector3 to a Vector4.

ToVector4 ( this vector, bool ground = false ) : System.Vector4

Converts the Vector2 to Vector4. Populates the Z property of the returned value with ground data if requested.

Private Methods

Method Description
FindAngleBetween ( this first, System.Vector3 second, bool radian = false ) : float

Method Details

Distance() public static method

Extension wrapper for Vector2.Distance method
public static Distance ( this v1, System.Vector2 v2 ) : float
v1 this First vector
v2 System.Vector2 Second vector
return float

Distance() public static method

Extension wrapper for Vector3.Distance method
public static Distance ( this v1, System.Vector3 v2 ) : float
v1 this First vector
v2 System.Vector3 Second vector
return float

Distance() public static method

Extension wrapper for Vector4.Distance method
public static Distance ( this v1, System.Vector4 v2 ) : float
v1 this First vector
v2 System.Vector4 Second vector
return float

Distance2D() public static method

Extension wrapper for Vector2.Distance method, to calculate distance between a vector and a unit
public static Distance2D ( this vector, System.Entity unit ) : float
vector this Vector
unit System.Entity Unit
return float

Distance2D() public static method

Extension wrapper for Vector2.Distance method
public static Distance2D ( this v1, System.Vector3 v2 ) : float
v1 this First vector
v2 System.Vector3 Second vector
return float

Distance2D() public static method

Extension wrapper for Vector2.Distance method
public static Distance2D ( this v1, System.Vector4 v2 ) : float
v1 this First vector
v2 System.Vector4 Second vector
return float

Distance3D() public static method

Extension wrapper for Vector3.Distance method
public static Distance3D ( this v1, System.Vector4 v2 ) : float
v1 this First vector
v2 System.Vector4 Second vector
return float

FindAngleBetween() public static method

Calculates the angle between a vector and a unit. The angle represents at which direction the unit resides in compared to vector. Returns degree values on default, radian if requested.
public static FindAngleBetween ( this first, System.Entity unit, bool radian = false ) : float
first this
unit System.Entity
radian bool Should the format be radian
return float

FindAngleBetween() public static method

Calculates the angle between two vectors. The angle represents at which direction the second vector resides in compared to first vector. Returns degree values on default, radian if requested.
public static FindAngleBetween ( this first, System.Vector2 second, bool radian = false ) : float
first this First Vector
second System.Vector2 Second Vector
radian bool Should the format be radian
return float

FromPolarAngle() public static method

Constructs a Unit Vector2 from polar angle
public static FromPolarAngle ( float polar ) : System.Vector2
polar float Polar angle of the vector
return System.Vector2

FromPolarCoordinates() public static method

Constructs a Vector2 from polar coordinates.
public static FromPolarCoordinates ( float radial, float polar ) : System.Vector2
radial float Radial of the vector
polar float Polar angle of the vector
return System.Vector2

IsValid() public static method

Returns true if the vector is valid.
public static IsValid ( this v ) : bool
v this
return bool

PolarAngle() public static method

Calculates the polar angle of the given vector. Returns degree values on default, radian if requested.
public static PolarAngle ( this vector, bool radian = false ) : float
vector this Vector whose polar angle will be returned
radian bool Should the format be radian
return float

Rotate() public static method

Rotates the given vector by given angle relative to zero vector.
public static Rotate ( this vector, float delta ) : System.Vector2
vector this Vector to be rotated
delta float Rotation represented in radians
return System.Vector2

Rotate() public static method

Rotates the given vector by given angle relative to given origin
public static Rotate ( this vector, float delta, System.Vector2 origin ) : System.Vector2
vector this Vector to be rotated
delta float Rotation represented in radians
origin System.Vector2 Origin vector
return System.Vector2

SwitchYZ() public static method

public static SwitchYZ ( this v ) : System.Vector3
v this
return System.Vector3

ToVector2() public static method

Converts the given Vector3 to a Vector2. Disregards Z property.
public static ToVector2 ( this vector ) : System.Vector2
vector this Vector to be converted
return System.Vector2

ToVector3() public static method

Converts the given Vector4 to a Vector3. Disregards W property.
public static ToVector3 ( this vector ) : System.Vector3
vector this Vector to be converted
return System.Vector3

ToVector3() public static method

Converts the Vector2 to Vector3. Populates the Z property of the returned value with ground data if requested.
public static ToVector3 ( this vector, bool ground = false ) : System.Vector3
vector this Source Vector2
ground bool Boolean value representing if the ground position should be found
return System.Vector3

ToVector4() public static method

Converts the given Vector3 to a Vector4.
public static ToVector4 ( this vector ) : System.Vector4
vector this Vector to be converted
return System.Vector4

ToVector4() public static method

Converts the Vector2 to Vector4. Populates the Z property of the returned value with ground data if requested.
public static ToVector4 ( this vector, bool ground = false ) : System.Vector4
vector this Source Vector2
ground bool Boolean value representing if the ground position should be found
return System.Vector4