Generated by DocFX

Struct Vector3

3D Vector structure with X, Y and Z coordinates.

Namespace: ISynergy.Framework.Mathematics
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public struct Vector3
Remarks

The structure incapsulates X, Y and Z coordinates of a 3D vector and provides some operations with it.

Constructors

View Source

Vector3(Single)

Initializes a new instance of the Vector3 structure.

Declaration
public Vector3(float value)
Parameters
Type Name Description
System.Single value

Value, which is set to all 3 coordinates of the vector.

View Source

Vector3(Single, Single, Single)

Initializes a new instance of the Vector3 structure.

Declaration
public Vector3(float x, float y, float z)
Parameters
Type Name Description
System.Single x

X coordinate of the vector.

System.Single y

Y coordinate of the vector.

System.Single z

Z coordinate of the vector.

Fields

View Source

X

X coordinate of the vector.

Declaration
public float X
Field Value
Type Description
System.Single
View Source

Y

Y coordinate of the vector.

Declaration
public float Y
Field Value
Type Description
System.Single
View Source

Z

Z coordinate of the vector.

Declaration
public float Z
Field Value
Type Description
System.Single

Properties

View Source

Max

Returns maximum value of the vector.

Declaration
public readonly float Max { get; }
Property Value
Type Description
System.Single
Remarks

Returns maximum value of all 3 vector's coordinates.

View Source

MaxIndex

Returns index of the coordinate with maximum value.

Declaration
public readonly int MaxIndex { get; }
Property Value
Type Description
System.Int32
Remarks

Returns index of the coordinate, which has the maximum value - 0 for X, 1 for Y or 2 for Z.

note

If there are multiple coordinates which have the same maximum value, the property returns smallest index.

View Source

Min

Returns minimum value of the vector.

Declaration
public readonly float Min { get; }
Property Value
Type Description
System.Single
Remarks

Returns minimum value of all 3 vector's coordinates.

View Source

MinIndex

Returns index of the coordinate with minimum value.

Declaration
public readonly int MinIndex { get; }
Property Value
Type Description
System.Int32
Remarks

Returns index of the coordinate, which has the minimum value - 0 for X, 1 for Y or 2 for Z.

note

If there are multiple coordinates which have the same minimum value, the property returns smallest index.

View Source

Norm

Returns vector's norm.

Declaration
public readonly float Norm { get; }
Property Value
Type Description
System.Single
Remarks

Returns Euclidean norm of the vector, which is a square root of the sum: X2+Y2+Z2.

View Source

Square

Returns square of the vector's norm.

Declaration
public readonly float Square { get; }
Property Value
Type Description
System.Single
Remarks

Return X2+Y2+Z2, which is a square of vector's norm or a dot product of this vector with itself.

Methods

View Source

Abs()

Calculate absolute values of the vector.

Declaration
public Vector3 Abs()
Returns
Type Description
Vector3

Returns a vector with all coordinates equal to absolute values of this vector's coordinates.

View Source

Add(Vector3, Vector3)

Adds corresponding coordinates of two vectors.

Declaration
public static Vector3 Add(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The vector to add to.

Vector3 vector2

The vector to add to the first vector.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to sum of corresponding coordinates of the two specified vectors.

View Source

Add(Vector3, Single)

Adds a value to all coordinates of the specified vector.

Declaration
public static Vector3 Add(Vector3 vector, float value)
Parameters
Type Name Description
Vector3 vector

Vector to add the specified value to.

System.Single value

Value to add to all coordinates of the vector.

Returns
Type Description
Vector3

Returns new vector with all coordinates increased by the specified value.

View Source

Cross(Vector3, Vector3)

Calculates cross product of two vectors.

Declaration
public static Vector3 Cross(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

First vector to use for cross product calculation.

Vector3 vector2

Second vector to use for cross product calculation.

Returns
Type Description
Vector3

Returns cross product of the two specified vectors.

View Source

Divide(Vector3, Vector3)

Divides corresponding coordinates of two vectors.

Declaration
public static Vector3 Divide(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The first vector to divide.

Vector3 vector2

The second vector to devide.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to coordinates of the first vector divided by corresponding coordinates of the second vector.

View Source

Divide(Vector3, Single)

Divides coordinates of the specified vector by the specified factor.

Declaration
public static Vector3 Divide(Vector3 vector, float factor)
Parameters
Type Name Description
Vector3 vector

Vector to divide coordinates of.

System.Single factor

Factor to divide coordinates of the specified vector by.

Returns
Type Description
Vector3

Returns new vector with all coordinates divided by the specified factor.

View Source

Dot(Vector3, Vector3)

Calculates dot product of two vectors.

Declaration
public static float Dot(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

First vector to use for dot product calculation.

Vector3 vector2

Second vector to use for dot product calculation.

Returns
Type Description
System.Single

Returns dot product of the two specified vectors.

View Source

Equals(Vector3)

Tests whether the vector equals to the specified one.

Declaration
public bool Equals(Vector3 vector)
Parameters
Type Name Description
Vector3 vector

The vector to test equality with.

Returns
Type Description
System.Boolean

Returns true if the two vectors are equal or false otherwise.

View Source

Equals(Object)

Tests whether the vector equals to the specified object.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The object to test equality with.

Returns
Type Description
System.Boolean

Returns true if the vector equals to the specified object or false otherwise.

View Source

GetHashCode()

Returns the hashcode for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

A 32-bit signed integer hash code.

View Source

Inverse()

Inverse the vector.

Declaration
public Vector3 Inverse()
Returns
Type Description
Vector3

Returns a vector with all coordinates equal to 1.0 divided by the value of corresponding coordinate in this vector (or equal to 0.0 if this vector has corresponding coordinate also set to 0.0).

View Source

Multiply(Vector3, Vector3)

Multiplies corresponding coordinates of two vectors.

Declaration
public static Vector3 Multiply(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The first vector to multiply.

Vector3 vector2

The second vector to multiply.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to multiplication of corresponding coordinates of the two specified vectors.

View Source

Multiply(Vector3, Single)

Multiplies coordinates of the specified vector by the specified factor.

Declaration
public static Vector3 Multiply(Vector3 vector, float factor)
Parameters
Type Name Description
Vector3 vector

Vector to multiply coordinates of.

System.Single factor

Factor to multiple coordinates of the specified vector by.

Returns
Type Description
Vector3

Returns new vector with all coordinates multiplied by the specified factor.

View Source

Normalize()

Normalizes the vector by dividing it’s all coordinates with the vector's norm.

Declaration
public float Normalize()
Returns
Type Description
System.Single

Returns the value of vectors’ norm before normalization.

View Source

Subtract(Vector3, Vector3)

Subtracts corresponding coordinates of two vectors.

Declaration
public static Vector3 Subtract(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The vector to subtract from.

Vector3 vector2

The vector to subtract from the first vector.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to difference of corresponding coordinates of the two specified vectors.

View Source

Subtract(Vector3, Single)

Subtracts a value from all coordinates of the specified vector.

Declaration
public static Vector3 Subtract(Vector3 vector, float value)
Parameters
Type Name Description
Vector3 vector

Vector to subtract the specified value from.

System.Single value

Value to subtract from all coordinates of the vector.

Returns
Type Description
Vector3

Returns new vector with all coordinates decreased by the specified value.

View Source

ToArray()

Returns array representation of the vector.

Declaration
public float[] ToArray()
Returns
Type Description
System.Single[]

Array with 3 values containing X/Y/Z coordinates.

View Source

ToString()

Returns a string representation of this object.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string representation of this object.

View Source

ToVector4()

Converts the vector to a 4D vector.

Declaration
public Vector4 ToVector4()
Returns
Type Description
Vector4

Returns 4D vector which is an extension of the 3D vector.

Remarks

The method returns a 4D vector which has X, Y and Z coordinates equal to the coordinates of this 3D vector and W coordinate set to 1.0.

Operators

View Source

Addition(Vector3, Vector3)

Adds corresponding coordinates of two vectors.

Declaration
public static Vector3 operator +(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The vector to add to.

Vector3 vector2

The vector to add to the first vector.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to sum of corresponding coordinates of the two specified vectors.

View Source

Addition(Vector3, Single)

Adds a value to all coordinates of the specified vector.

Declaration
public static Vector3 operator +(Vector3 vector, float value)
Parameters
Type Name Description
Vector3 vector

Vector to add the specified value to.

System.Single value

Value to add to all coordinates of the vector.

Returns
Type Description
Vector3

Returns new vector with all coordinates increased by the specified value.

View Source

Division(Vector3, Vector3)

Divides corresponding coordinates of two vectors.

Declaration
public static Vector3 operator /(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The first vector to divide.

Vector3 vector2

The second vector to devide.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to coordinates of the first vector divided by corresponding coordinates of the second vector.

View Source

Division(Vector3, Single)

Divides coordinates of the specified vector by the specified factor.

Declaration
public static Vector3 operator /(Vector3 vector, float factor)
Parameters
Type Name Description
Vector3 vector

Vector to divide coordinates of.

System.Single factor

Factor to divide coordinates of the specified vector by.

Returns
Type Description
Vector3

Returns new vector with all coordinates divided by the specified factor.

View Source

Equality(Vector3, Vector3)

Tests whether two specified vectors are equal.

Declaration
public static bool operator ==(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The left-hand vector.

Vector3 vector2

The right-hand vector.

Returns
Type Description
System.Boolean

Returns true if the two vectors are equal or false otherwise.

View Source

Inequality(Vector3, Vector3)

Tests whether two specified vectors are not equal.

Declaration
public static bool operator !=(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The left-hand vector.

Vector3 vector2

The right-hand vector.

Returns
Type Description
System.Boolean

Returns true if the two vectors are not equal or false otherwise.

View Source

Multiply(Vector3, Vector3)

Multiplies corresponding coordinates of two vectors.

Declaration
public static Vector3 operator *(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The first vector to multiply.

Vector3 vector2

The second vector to multiply.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to multiplication of corresponding coordinates of the two specified vectors.

View Source

Multiply(Vector3, Single)

Multiplies coordinates of the specified vector by the specified factor.

Declaration
public static Vector3 operator *(Vector3 vector, float factor)
Parameters
Type Name Description
Vector3 vector

Vector to multiply coordinates of.

System.Single factor

Factor to multiple coordinates of the specified vector by.

Returns
Type Description
Vector3

Returns new vector with all coordinates multiplied by the specified factor.

View Source

Subtraction(Vector3, Vector3)

Subtracts corresponding coordinates of two vectors.

Declaration
public static Vector3 operator -(Vector3 vector1, Vector3 vector2)
Parameters
Type Name Description
Vector3 vector1

The vector to subtract from.

Vector3 vector2

The vector to subtract from the first vector.

Returns
Type Description
Vector3

Returns a vector which coordinates are equal to difference of corresponding coordinates of the two specified vectors.

View Source

Subtraction(Vector3, Single)

Subtracts a value from all coordinates of the specified vector.

Declaration
public static Vector3 operator -(Vector3 vector, float value)
Parameters
Type Name Description
Vector3 vector

Vector to subtract the specified value from.

System.Single value

Value to subtract from all coordinates of the vector.

Returns
Type Description
Vector3

Returns new vector with all coordinates decreased by the specified value.

Extension Methods

EnumExtensions.GetSymbol<T>(T)
ArrayExtensions.Concatenate<T>(T, T[])
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>, Func<TSource, Boolean>)
ObjectExtensions.Clone<T>(T)
ObjectExtensions.AddressOf<T>(T)
ObjectExtensions.ToByteArray<T>(T)
ReflectionExtensions.GetPropertyInfo<T, TValue>(T, Expression<Func<T, TValue>>)