KS.Reactor.ksVector2 Struct Reference

Vector2 struct. More...

Public Member Functions

 ksVector2 (float x, float y)
 Constructor. More...
 
float Magnitude ()
 Gets the magnitude. More...
 
float MagnitudeSquared ()
 Gets the magnitude squared. More...
 
ksVector2 Normalized ()
 Gets a normalized copy of this vector. More...
 
bool Normalize ()
 Normalizes this vector. More...
 
ksVector2 Clamped (float maxMagnitude)
 Returns a copy of this vector with its magnitude clamped to maxLength. More...
 
void Clamp (float maxMagnitude)
 Clamps the magnitude of this vector. More...
 
float ToDegrees ()
 Converts the direction of the vector to an angle. More...
 
float ToRadians ()
 Converts the direction of the vector to an angle. More...
 
ksVector2 Abs ()
 Absolute value vector. More...
 
float MaxValue (bool absolute=false)
 Gets the maximum component in the vector. More...
 
float MinValue (bool absolute=false)
 Gets the minimum component in the vector. More...
 
bool ReplaceNaNs (float value=0.0f)
 Replaces NaN values in the vector. More...
 
override string ToString ()
 Returns a string that represents the current Vector2. More...
 
string ToString (string format)
 Returns a string respresentation of the vector. More...
 
string ToString (IFormatProvider provider)
 Returns a string respresentation of the vector. More...
 
override bool Equals (object obj)
 Checks if this vector is equal to an object. More...
 
bool Equals (ksVector2 other)
 Checks if this vector is equal to another. More...
 
override int GetHashCode ()
 Gets the hash code for this vector. More...
 

Static Public Member Functions

static implicit operator float[] (ksVector2 value)
 Implicit conversion from ksVector2 to float[2]. More...
 
static implicit operator ksVector2 (float[] value)
 Implicit conversion from float[] to ksVector2. More...
 
static ksVector2 FromDegrees (float angle, float magnitude=1)
 Constructs a Vector2 from an angle. More...
 
static ksVector2 FromRadians (float angle, float magnitude=1)
 Constructs a Vector2 from an angle. More...
 
static float DeltaDegrees (ksVector2 from, ksVector2 to)
 Returns the angle in degrees between two vectors. More...
 
static float DeltaRadians (ksVector2 from, ksVector2 to)
 Returns the angle in radians between two vectors. More...
 
static float Dot (ksVector2 lhs, ksVector2 rhs)
 Computes the dot product of two vectors. More...
 
static ksVector2 Max (ksVector2 lhs, ksVector2 rhs)
 Returns a vector that is made from the largest components of two vectors. More...
 
static ksVector2 Min (ksVector2 lhs, ksVector2 rhs)
 Returns a vector that is made from the smallest components of two vectors. More...
 
static ksVector2 Project (ksVector2 vector, ksVector2 target)
 Projects a vector onto another vector. More...
 
static ksVector2 Reflect (ksVector2 direction, ksVector2 normal)
 Reflects a vector off the plane defined by a normal. More...
 
static ksVector2 Lerp (ksVector2 from, ksVector2 to, float t)
 Linearly interpolates between two vectors. More...
 
static ksVector2 Slerp (ksVector2 from, ksVector2 to, float t, bool lerpMagnitude=false)
 Spherically interpolates between from and to by t. More...
 
static ksVector2 MoveTowards (ksVector2 start, ksVector2 target, float delta)
 Moves a point towards a target point. More...
 
static ksVector2 Rotate (ksVector2 direction, float angle)
 Rotates a vector by an angle. More...
 
static ksVector2 RotateRadians (ksVector2 direction, float angle)
 Rotates a vector by an angle. More...
 
static ksVector2 Scale (ksVector2 a, ksVector2 b)
 Multiplies two vectors component-wise. More...
 
static ksVector2 operator- (ksVector2 lhs, ksVector2 rhs)
 Subtracts one vector from another. More...
 
static ksVector2 operator- (ksVector2 v)
 Multiplies the vector by -1. More...
 
static ksVector2 operator* (ksVector2 vector, float scale)
 Multiplies a ksVector2 by a number. More...
 
static ksVector2 operator* (float scale, ksVector2 vector)
 Multiplies a ksVector2 by a number. More...
 
static ksVector2 operator/ (ksVector2 vector, float scale)
 Divides a ksVector2 by a number. More...
 
static ksVector2 operator/ (float number, ksVector2 vector)
 Divides a number by a ksVector2. More...
 
static ksVector2 operator+ (ksVector2 lhs, ksVector2 rhs)
 Adds two ksVector2. More...
 
static bool operator== (ksVector2 lhs, ksVector2 rhs)
 Checks if two vectors are equal. More...
 
static bool operator!= (ksVector2 lhs, ksVector2 rhs)
 Checks if two vectors are not equal More...
 
static implicit operator Vector2 (ksVector2 value)
 Implicit conversion from ksVector2 to Unity Vector2. More...
 
static implicit operator ksVector2 (Vector2 value)
 Implicit conversion from Unity Vector2 to ksVector2. More...
 
static ksVector2 operator+ (ksVector2 lhs, Vector2 rhs)
 Vector addition with ksVector2 and Unity Vector2. More...
 
static Vector2 operator+ (Vector2 rhs, ksVector2 lhs)
 Vector addition with Unity Vector2 and ksVector2. More...
 
static ksVector2 operator- (ksVector2 lhs, Vector2 rhs)
 Vector subtraction with ksVector2 and Unity Vector2. More...
 
static Vector2 operator- (Vector2 lhs, ksVector2 rhs)
 Vector subtraction with Unity Vector2 and ksVector2. More...
 
static bool operator== (ksVector2 lhs, Vector2 rhs)
 Equality comparison with with ksVector2 and Unity Vector2. More...
 
static bool operator== (Vector2 lhs, ksVector2 rhs)
 Equality comparison with Unity Vector2 and ksVector2. More...
 
static bool operator!= (ksVector2 lhs, Vector2 rhs)
 Inequality comparison with with ksVector2 and Unity Vector2. More...
 
static bool operator!= (Vector2 lhs, ksVector2 rhs)
 Inequality comparison with Unity Vector2 and ksVector2. More...
 

Properties

static ksVector2 One [get]
 
static ksVector2 Zero [get]
 
float X [get, set]
 X value. More...
 
float Y [get, set]
 Y value. More...
 
float this[int index] [get, set]
 Indexer. More...
 

Detailed Description

Vector2 struct.

Vector struct

Constructor & Destructor Documentation

◆ ksVector2()

KS.Reactor.ksVector2.ksVector2 ( float  x,
float  y 
)

Constructor.

Parameters
xX value.
yY value.

Member Function Documentation

◆ Abs()

ksVector2 KS.Reactor.ksVector2.Abs ( )

Absolute value vector.

Returns
New vector where all components are absolue values of this vector.

◆ Clamp()

void KS.Reactor.ksVector2.Clamp ( float  maxMagnitude)

Clamps the magnitude of this vector.

Parameters
maxMagnitudeMax magnitude to clamp magnitude to.

◆ Clamped()

ksVector2 KS.Reactor.ksVector2.Clamped ( float  maxMagnitude)

Returns a copy of this vector with its magnitude clamped to maxLength.

Parameters
maxMagnitudeMax magnitude to clamp magnitude to.
Returns
Clamped vector.

◆ DeltaDegrees()

static float KS.Reactor.ksVector2.DeltaDegrees ( ksVector2  from,
ksVector2  to 
)
static

Returns the angle in degrees between two vectors.

Parameters
fromThe angle extends round from this vector.
toThe angle extends round to this vector.
Returns
Angle in degrees.

◆ DeltaRadians()

static float KS.Reactor.ksVector2.DeltaRadians ( ksVector2  from,
ksVector2  to 
)
static

Returns the angle in radians between two vectors.

Parameters
fromThe angle extends round from this vector.
toThe angle extends round to this vector.
Returns
Angle in radians.

◆ Dot()

static float KS.Reactor.ksVector2.Dot ( ksVector2  lhs,
ksVector2  rhs 
)
static

Computes the dot product of two vectors.

Parameters
lhs
rhs
Returns
Dot product.

◆ Equals() [1/2]

bool KS.Reactor.ksVector2.Equals ( ksVector2  other)

Checks if this vector is equal to another.

Parameters
otherOther vector to compare with.
Returns
True if the vectors are equal.

◆ Equals() [2/2]

override bool KS.Reactor.ksVector2.Equals ( object  obj)

Checks if this vector is equal to an object.

Parameters
objObject to compare with this vector.
Returns
True if this vector is equal to the object.

◆ FromDegrees()

static ksVector2 KS.Reactor.ksVector2.FromDegrees ( float  angle,
float  magnitude = 1 
)
static

Constructs a Vector2 from an angle.

Parameters
angleAngle in degrees.
magnitudeMagnitude
Returns

◆ FromRadians()

static ksVector2 KS.Reactor.ksVector2.FromRadians ( float  angle,
float  magnitude = 1 
)
static

Constructs a Vector2 from an angle.

Parameters
angleAngle in radians.
magnitudeMagnitude.
Returns

◆ GetHashCode()

override int KS.Reactor.ksVector2.GetHashCode ( )

Gets the hash code for this vector.

Returns

◆ Lerp()

static ksVector2 KS.Reactor.ksVector2.Lerp ( ksVector2  from,
ksVector2  to,
float  t 
)
static

Linearly interpolates between two vectors.

Parameters
fromVector to interpolate from.
toVector to interpolate to.
tValue between 0 and 1 that determines the amount of interpolation.
Returns
Interpolated vector.

◆ Magnitude()

float KS.Reactor.ksVector2.Magnitude ( )

Gets the magnitude.

Returns

◆ MagnitudeSquared()

float KS.Reactor.ksVector2.MagnitudeSquared ( )

Gets the magnitude squared.

Returns

◆ Max()

static ksVector2 KS.Reactor.ksVector2.Max ( ksVector2  lhs,
ksVector2  rhs 
)
static

Returns a vector that is made from the largest components of two vectors.

Parameters
lhs
rhs
Returns
Max vector.

◆ MaxValue()

float KS.Reactor.ksVector2.MaxValue ( bool  absolute = false)

Gets the maximum component in the vector.

Parameters
absoluteReturn the max absolute value.
Returns
Max component value.

◆ Min()

static ksVector2 KS.Reactor.ksVector2.Min ( ksVector2  lhs,
ksVector2  rhs 
)
static

Returns a vector that is made from the smallest components of two vectors.

Parameters
lhs
rhs
Returns
Min vector.

◆ MinValue()

float KS.Reactor.ksVector2.MinValue ( bool  absolute = false)

Gets the minimum component in the vector.

Parameters
absoluteReturn the min absolute value.
Returns
Min component value.

◆ MoveTowards()

static ksVector2 KS.Reactor.ksVector2.MoveTowards ( ksVector2  start,
ksVector2  target,
float  delta 
)
static

Moves a point towards a target point.

Parameters
startstart point.
targettarget to move towards.
deltaDelta distance to move. It will not overshoot the target. Negative values will move away from the target.
Returns

◆ Normalize()

bool KS.Reactor.ksVector2.Normalize ( )

Normalizes this vector.

Returns
False if the vector could not be normalized because it's the zero vector.

◆ Normalized()

ksVector2 KS.Reactor.ksVector2.Normalized ( )

Gets a normalized copy of this vector.

Returns

◆ operator float[]()

static implicit KS.Reactor.ksVector2.operator float[] ( ksVector2  value)
static

Implicit conversion from ksVector2 to float[2].

Parameters
value

◆ operator ksVector2() [1/2]

static implicit KS.Reactor.ksVector2.operator ksVector2 ( float[]  value)
static

Implicit conversion from float[] to ksVector2.

Parameters
value

◆ operator ksVector2() [2/2]

static implicit KS.Reactor.ksVector2.operator ksVector2 ( Vector2  value)
static

Implicit conversion from Unity Vector2 to ksVector2.

Parameters
valueUnity vector
Returns
Reactor vector

◆ operator Vector2()

static implicit KS.Reactor.ksVector2.operator Vector2 ( ksVector2  value)
static

Implicit conversion from ksVector2 to Unity Vector2.

Parameters
valueReactor vector
Returns
Unity vector

◆ operator!=() [1/3]

static bool KS.Reactor.ksVector2.operator!= ( ksVector2  lhs,
ksVector2  rhs 
)
static

Checks if two vectors are not equal

Parameters
lhs
rhs
Returns
True if the vectors are not equal.

◆ operator!=() [2/3]

static bool KS.Reactor.ksVector2.operator!= ( ksVector2  lhs,
Vector2  rhs 
)
static

Inequality comparison with with ksVector2 and Unity Vector2.

Parameters
lhs
rhs
Returns
lhs != rhs

◆ operator!=() [3/3]

static bool KS.Reactor.ksVector2.operator!= ( Vector2  lhs,
ksVector2  rhs 
)
static

Inequality comparison with Unity Vector2 and ksVector2.

Parameters
lhs
rhs
Returns
lhs != rhs

◆ operator*() [1/2]

static ksVector2 KS.Reactor.ksVector2.operator* ( float  scale,
ksVector2  vector 
)
static

Multiplies a ksVector2 by a number.

Multiplies each component of Vector2 by a number scale.

Parameters
scale
vector
Returns

◆ operator*() [2/2]

static ksVector2 KS.Reactor.ksVector2.operator* ( ksVector2  vector,
float  scale 
)
static

Multiplies a ksVector2 by a number.

Multiplies each component of Vector2 by a number scale.

Parameters
vector
scale
Returns

◆ operator+() [1/3]

static ksVector2 KS.Reactor.ksVector2.operator+ ( ksVector2  lhs,
ksVector2  rhs 
)
static

Adds two ksVector2.

Parameters
lhs
rhs
Returns

◆ operator+() [2/3]

static ksVector2 KS.Reactor.ksVector2.operator+ ( ksVector2  lhs,
Vector2  rhs 
)
static

Vector addition with ksVector2 and Unity Vector2.

Parameters
lhs
rhs
Returns
lhs + rhs

◆ operator+() [3/3]

static Vector2 KS.Reactor.ksVector2.operator+ ( Vector2  rhs,
ksVector2  lhs 
)
static

Vector addition with Unity Vector2 and ksVector2.

Parameters
lhs
rhs
Returns
lhs + rhs

◆ operator-() [1/4]

static ksVector2 KS.Reactor.ksVector2.operator- ( ksVector2  lhs,
ksVector2  rhs 
)
static

Subtracts one vector from another.

Parameters
lhs
rhs
Returns

◆ operator-() [2/4]

static ksVector2 KS.Reactor.ksVector2.operator- ( ksVector2  lhs,
Vector2  rhs 
)
static

Vector subtraction with ksVector2 and Unity Vector2.

Parameters
lhs
rhs
Returns
lhs - rhs

◆ operator-() [3/4]

static ksVector2 KS.Reactor.ksVector2.operator- ( ksVector2  v)
static

Multiplies the vector by -1.

Parameters
v
Returns

◆ operator-() [4/4]

static Vector2 KS.Reactor.ksVector2.operator- ( Vector2  lhs,
ksVector2  rhs 
)
static

Vector subtraction with Unity Vector2 and ksVector2.

Parameters
lhs
rhs
Returns
lhs - rhs

◆ operator/() [1/2]

static ksVector2 KS.Reactor.ksVector2.operator/ ( float  number,
ksVector2  vector 
)
static

Divides a number by a ksVector2.

Parameters
number
vector
Returns

◆ operator/() [2/2]

static ksVector2 KS.Reactor.ksVector2.operator/ ( ksVector2  vector,
float  scale 
)
static

Divides a ksVector2 by a number.

Parameters
vector
scale
Returns

◆ operator==() [1/3]

static bool KS.Reactor.ksVector2.operator== ( ksVector2  lhs,
ksVector2  rhs 
)
static

Checks if two vectors are equal.

Parameters
lhs
rhs
Returns
True if the vectors are equal.

◆ operator==() [2/3]

static bool KS.Reactor.ksVector2.operator== ( ksVector2  lhs,
Vector2  rhs 
)
static

Equality comparison with with ksVector2 and Unity Vector2.

Parameters
lhs
rhs
Returns
lhs == rhs

◆ operator==() [3/3]

static bool KS.Reactor.ksVector2.operator== ( Vector2  lhs,
ksVector2  rhs 
)
static

Equality comparison with Unity Vector2 and ksVector2.

Parameters
lhs
rhs
Returns
lhs == rhs

◆ Project()

static ksVector2 KS.Reactor.ksVector2.Project ( ksVector2  vector,
ksVector2  target 
)
static

Projects a vector onto another vector.

Parameters
vectorVector to project.
targetTarget to project onto.
Returns
Projection result.

◆ Reflect()

static ksVector2 KS.Reactor.ksVector2.Reflect ( ksVector2  direction,
ksVector2  normal 
)
static

Reflects a vector off the plane defined by a normal.

Parameters
directionDirection to reflect.
normalNormal of plane to reflect off of.
Returns
Reflected vector.

◆ ReplaceNaNs()

bool KS.Reactor.ksVector2.ReplaceNaNs ( float  value = 0.0f)

Replaces NaN values in the vector.

Parameters
valueReplacement value.
Returns
True if any of the values was replaced.

◆ Rotate()

static ksVector2 KS.Reactor.ksVector2.Rotate ( ksVector2  direction,
float  angle 
)
static

Rotates a vector by an angle.

Parameters
directionDirection to rotate.
angleAngle in degrees.
Returns
Rotated vector.

◆ RotateRadians()

static ksVector2 KS.Reactor.ksVector2.RotateRadians ( ksVector2  direction,
float  angle 
)
static

Rotates a vector by an angle.

Parameters
directionDirection to rotate.
angleAngle in radians.
Returns
Rotated vector.

◆ Scale()

static ksVector2 KS.Reactor.ksVector2.Scale ( ksVector2  a,
ksVector2  b 
)
static

Multiplies two vectors component-wise.

Parameters
a
b
Returns

◆ Slerp()

static ksVector2 KS.Reactor.ksVector2.Slerp ( ksVector2  from,
ksVector2  to,
float  t,
bool  lerpMagnitude = false 
)
static

Spherically interpolates between from and to by t.

Parameters
fromVector to interpolate from.
toVector to interpolate to.
tValue between 0 and 1 that determines the amount of interpolation.
lerpMagnitudeIf false, magnitude won't be interpolated.
Returns
Interpolated vector.

◆ ToDegrees()

float KS.Reactor.ksVector2.ToDegrees ( )

Converts the direction of the vector to an angle.

Returns
Angle in degrees [0, 360).

◆ ToRadians()

float KS.Reactor.ksVector2.ToRadians ( )

Converts the direction of the vector to an angle.

Returns
Angle in radians [0, 2PI).

◆ ToString() [1/3]

override string KS.Reactor.ksVector2.ToString ( )

Returns a string that represents the current Vector2.

Returns
A string that represents the current Vector2.

◆ ToString() [2/3]

string KS.Reactor.ksVector2.ToString ( IFormatProvider  provider)

Returns a string respresentation of the vector.

Parameters
provider
Returns
Representation of the vector.

◆ ToString() [3/3]

string KS.Reactor.ksVector2.ToString ( string  format)

Returns a string respresentation of the vector.

Parameters
format
Returns
Representation of the vector.

Property Documentation

◆ this[int index]

float KS.Reactor.ksVector2.this[int index]
getset

Indexer.

Parameters
index
Returns

◆ X

float KS.Reactor.ksVector2.X
getset

X value.

◆ Y

float KS.Reactor.ksVector2.Y
getset

Y value.