Table of Contents

Struct Vector

Namespace
VirtualLabAPI.Core.Numerics
Assembly
VirtualLabAPI.dll

This struct defines a two-dimensional vector of integer numbers. Operators \(a+b\), \(a-b\) and \(a|b\) (Scalar product) can be used. One operand on \(a*b\) and \(a/b\) can be an integer too. Implicit casting to System.Drawing.Point and System.Drawing.Size is supported.

[Serializable]
public struct Vector
Inherited Members

Constructors

Vector(int, int)

Creates a Vector from two int values.

public Vector(int x, int y)

Parameters

x int

x-value of new Vector object.

y int

y-value of new Vector object.

Vector(Vector)

Copy constructor.

public Vector(Vector v)

Parameters

v Vector

Vector to be copied.

Fields

MaxValue

A constant containing the minimum allowed vector.

public static readonly Vector MaxValue

Field Value

Vector

MinValue

A constant containing the minimum allowed vector.

public static readonly Vector MinValue

Field Value

Vector

UnitVectorX

A constant containing the unit vector in x-direction.

public static readonly Vector UnitVectorX

Field Value

Vector

UnitVectorY

A constant containing the unit vector in y-direction.

public static readonly Vector UnitVectorY

Field Value

Vector

X

x-value of the Vector object.

[NonSerialized]
public int X

Field Value

int

Y

y-value of the Vector object.

[NonSerialized]
public int Y

Field Value

int

ZeroVector

A constant containing the zero vector (0, 0).

public static readonly Vector ZeroVector

Field Value

Vector

Methods

Equals(object)

This function compares the values of this object and the object given as parameter for equality.

public override bool Equals(object obj)

Parameters

obj object

Vector to be compared.

Returns

bool

Returns true if both object pointers are equal.

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Max(Vector)

Returns the largest component of a Vector.

public static int Max(Vector a)

Parameters

a Vector

The vector to check.

Returns

int

The component of the vector having the largest value.

Parse(string)

Converts a string generated by the ToString method back into a Vector object.

public static Vector Parse(string stringToParse)

Parameters

stringToParse string

The string to be parsed.

Returns

Vector

A Vector object.

ToString()

Converts a Vector into a string of format (X; Y).

public override string ToString()

Returns

string

String containing the Vector information.

Operators

operator +(Vector, Vector)

Adds two Vector objects.

public static Vector operator +(Vector a, Vector b)

Parameters

a Vector

The first Vector object to add.

b Vector

The second Vector object to add.

Returns

Vector

Returns the sum of the two \markAsCode{Vector} objects.

operator |(Vector, Vector)

Calculates the scalar product of two Vector objects.

public static int operator |(Vector a, Vector b)

Parameters

a Vector

First Vector object.

b Vector

Second Vector object.

Returns

int

Scalar product of the two Vector objects.

operator /(int, Vector)

Performs a component-wise division of an int value and a Vector object. The result is defined as new Vector(number / vector.X, number / vector.Y).

public static Vector operator /(int number, Vector vector)

Parameters

number int

The integer value to divide by the components of the Vector object.

vector Vector

The Vector object used as divisor.

Returns

Vector

Returns the quotient of the integer value and the Vector object.

operator /(Vector, int)

Performs a component-wise division of a Vector object and an int value.

public static Vector operator /(Vector vector, int divisor)

Parameters

vector Vector

The Vector object to divide by the integer value.

divisor int

The integer value used as divisor.

Returns

Vector

Returns the quotient of the Vector object and the integer value.

operator /(Vector, Vector)

Performs a component-wise division of two Vector objects.

public static Vector operator /(Vector a, Vector b)

Parameters

a Vector

The first Vector object to divide by parameter b.

b Vector

The second Vector object used as divisor.

Returns

Vector

Returns the quotient of the two Vector objects.

operator ==(Vector, Vector)

Compares two Vector for equality. The comparison will be done by comparing the values of the two x- and y-components, respectively.

public static bool operator ==(Vector vector1, Vector vector2)

Parameters

vector1 Vector

First Vector object to compare.

vector2 Vector

Second Vector object to compare.

Returns

bool

Returns true if the two objects are equal.

explicit operator Vector(VectorD)

Converts a VectorD object to a Vector object.

public static explicit operator Vector(VectorD vector)

Parameters

vector VectorD

VectorD object to be converted.

Returns

Vector

Converted Vector.

operator !=(Vector, Vector)

Compares two Vector for inequality. The comparison will be done by comparing the values of the two x- and y-components, respectively.

public static bool operator !=(Vector vector1, Vector vector2)

Parameters

vector1 Vector

First Vector object to compare.

vector2 Vector

Second Vector object to compare.

Returns

bool

Returns true if the two objects are unequal.

operator *(int, Vector)

Multiplies a Vector object with an int value.

public static Vector operator *(int factor, Vector vector)

Parameters

factor int

The integer value to multiply.

vector Vector

The Vector object to multiply.

Returns

Vector

Returns the product of the Vector object and the integer value.

operator *(Vector, int)

Multiplies a Vector object by an int value.

public static Vector operator *(Vector vector, int factor)

Parameters

vector Vector

The Vector object to multiply.

factor int

The integer value to multiply.

Returns

Vector

Returns the product of the Vector object and the integer value.

operator *(Vector, Vector)

Multiplies two Vector objects.

public static Vector operator *(Vector a, Vector b)

Parameters

a Vector

The first Vector object to multiply.

b Vector

The second Vector object to multiply.

Returns

Vector

Returns the product of the two Vector objects.

operator -(Vector, Vector)

Subtracts two Vector objects.

public static Vector operator -(Vector a, Vector b)

Parameters

a Vector

The first Vector object to subtract from.

b Vector

The second Vector object to subtract.

Returns

Vector

Returns the difference of the two Vector objects.