[]
        
(Showing Draft Content)

GrapeCity.Documents.DX.Vector4

Struct Vector4

Namespace
GrapeCity.Documents.DX
Assembly
GcDocs.DX.Windows.dll

Represents a four dimensional mathematical vector.

public struct Vector4 : IEquatable<Vector4>, IFormattable
Implements
System.IEquatable<T><Vector4>
System.IFormattable
Inherited Members
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()

Constructors

Vector4(Vector2, float, float)

Initializes a new instance of the Vector4 struct.

public Vector4(Vector2 value, float z, float w)

Parameters

value Vector2

A vector containing the values with which to initialize the X and Y components.

z float

Initial value for the Z component of the vector.

w float

Initial value for the W component of the vector.

Vector4(Vector3, float)

Initializes a new instance of the Vector4 struct.

public Vector4(Vector3 value, float w)

Parameters

value Vector3

A vector containing the values with which to initialize the X, Y, and Z components.

w float

Initial value for the W component of the vector.

Vector4(float, float, float, float)

Initializes a new instance of the Vector4 struct.

public Vector4(float x, float y, float z, float w)

Parameters

x float

Initial value for the X component of the vector.

y float

Initial value for the Y component of the vector.

z float

Initial value for the Z component of the vector.

w float

Initial value for the W component of the vector.

Vector4(float)

Initializes a new instance of the Vector4 struct.

public Vector4(float value)

Parameters

value float

The value that will be assigned to all components.

Vector4(float[])

Initializes a new instance of the Vector4 struct.

public Vector4(float[] values)

Parameters

values float[]

The values to assign to the X, Y, Z, and W components of the vector. This must be an array with four elements.

Exceptions

System.ArgumentNullException

Thrown when values is null.

System.ArgumentOutOfRangeException

Thrown when values contains more or less than four elements.

Fields

One

A Vector4 with all of its components set to one.

public static readonly Vector4 One

Field Value

Vector4

SizeInBytes

The size of the Vector4 type, in bytes.

public const int SizeInBytes = 16

Field Value

int

UnitW

The W unit Vector4 (0, 0, 0, 1).

public static readonly Vector4 UnitW

Field Value

Vector4

UnitX

The X unit Vector4 (1, 0, 0, 0).

public static readonly Vector4 UnitX

Field Value

Vector4

UnitY

The Y unit Vector4 (0, 1, 0, 0).

public static readonly Vector4 UnitY

Field Value

Vector4

UnitZ

The Z unit Vector4 (0, 0, 1, 0).

public static readonly Vector4 UnitZ

Field Value

Vector4

W

The W component of the vector.

public float W

Field Value

float

X

The X component of the vector.

public float X

Field Value

float

Y

The Y component of the vector.

public float Y

Field Value

float

Z

The Z component of the vector.

public float Z

Field Value

float

Zero

A Vector4 with all of its components set to zero.

public static readonly Vector4 Zero

Field Value

Vector4

Properties

IsNormalized

Gets a value indicting whether this instance is normalized.

public bool IsNormalized { get; }

Property Value

bool

this[int]

Gets or sets the component at the specified index.

public float this[int index] { get; set; }

Parameters

index int

The index of the component to access. Use 0 for the X component, 1 for the Y component, 2 for the Z component, and 3 for the W component.

Property Value

float

The value of the X, Y, Z, or W component, depending on the index.

Exceptions

System.ArgumentOutOfRangeException

Thrown when the index is out of the range [0, 3].

Length

Gets the length of the vector.

public float Length { get; }

Property Value

float

LengthSquared

Gets the squared length of the vector.

public float LengthSquared { get; }

Property Value

float

Methods

Abs(Vector4)

Returns a vector whose elements are the absolute values of each of the specified vector's elements.

public static Vector4 Abs(Vector4 value)

Parameters

value Vector4

A vector.

Returns

Vector4

The absolute value vector.

AbsRef(ref Vector4)

Calculates the absolute value vector.

public static void AbsRef(ref Vector4 value)

Parameters

value Vector4

A vector.

Add(Vector4, Vector4)

Adds two vectors.

public static Vector4 Add(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector to add.

right Vector4

The second vector to add.

Returns

Vector4

The sum of the two vectors.

Clamp(Vector4, Vector4, Vector4)

Restricts a vector between a minimum and a maximum value.

public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4 max)

Parameters

value Vector4

The vector to restrict.

min Vector4

The minimum value.

max Vector4

The maximum value.

Returns

Vector4

The restricted vector.

Divide(Vector4, Vector4)

Divides the first vector by the second.

public static Vector4 Divide(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector.

right Vector4

The second vector.

Returns

Vector4

The vector resulting from the division.

Divide(Vector4, float)

Divides the specified vector by a specified scalar value.

public static Vector4 Divide(Vector4 left, float divisor)

Parameters

left Vector4

The vector.

divisor float

The scalar value.

Returns

Vector4

The vector that results from the division.

Dot(Vector4, Vector4)

Calculates the dot product of two vectors.

public static float Dot(Vector4 left, Vector4 right)

Parameters

left Vector4

First source vector.

right Vector4

Second source vector.

Returns

float

The dot product of the two vectors.

Equals(Vector4)

Determines whether the specified Vector4 is equal to this instance.

public bool Equals(Vector4 other)

Parameters

other Vector4

Returns

bool

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object value)

Parameters

value object

Returns

bool

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.

Lerp(Vector4, Vector4, float)

Performs a linear interpolation between two vectors based on the given weighting.

public static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)

Parameters

value1 Vector4

The first vector.

value2 Vector4

The second vector.

amount float

A value between 0 and 1 that indicates the weight of value2.

Returns

Vector4

The interpolated vector.

Max(Vector4, Vector4)

Returns a vector containing the largest components of the specified vectors.

public static Vector4 Max(Vector4 left, Vector4 right)

Parameters

left Vector4

The first source vector.

right Vector4

The second source vector.

Returns

Vector4

A vector containing the largest components of the source vectors.

Min(Vector4, Vector4)

Returns a vector containing the smallest components of the specified vectors.

public static Vector4 Min(Vector4 left, Vector4 right)

Parameters

left Vector4

The first source vector.

right Vector4

The second source vector.

Returns

Vector4

A vector containing the smallest components of the source vectors.

Multiply(Vector4, Vector4)

Modulates a vector with another by performing component-wise multiplication.

public static Vector4 Multiply(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector to modulate.

right Vector4

The second vector to modulate.

Returns

Vector4

The modulated vector.

Multiply(Vector4, float)

Scales a vector by the given value.

public static Vector4 Multiply(Vector4 value, float scale)

Parameters

value Vector4

The vector to scale.

scale float

The amount by which to scale the vector.

Returns

Vector4

The scaled vector.

Negate(Vector4)

Reverses the direction of a given vector.

public static Vector4 Negate(Vector4 value)

Parameters

value Vector4

The vector to negate.

Returns

Vector4

A vector facing in the opposite direction.

NegateRef(ref Vector4)

Reverses the direction of the vector.

public static void NegateRef(ref Vector4 value)

Parameters

value Vector4

The vector to negate.

Normalize(Vector4)

Converts the vector into a unit vector.

public static Vector4 Normalize(Vector4 value)

Parameters

value Vector4

The vector to normalize.

Returns

Vector4

The normalized vector.

NormalizeRef(ref Vector4)

Converts the vector into a unit vector.

public static void NormalizeRef(ref Vector4 value)

Parameters

value Vector4

The vector to normalize.

Subtract(Vector4, Vector4)

Subtracts two vectors.

public static Vector4 Subtract(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector to subtract.

right Vector4

The second vector to subtract.

Returns

Vector4

The difference of the two vectors.

ToArray()

Creates an array containing the elements of the vector.

public float[] ToArray()

Returns

float[]

A four-element array containing the components of the vector.

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

ToString(IFormatProvider)

Returns a string that represents this instance.

public string ToString(IFormatProvider formatProvider)

Parameters

formatProvider System.IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

ToString(string, IFormatProvider)

Returns a string that represents this instance.

public string ToString(string format, IFormatProvider formatProvider)

Parameters

format string

The format.

formatProvider System.IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

ToString(string)

Returns a string that represents this instance.

public string ToString(string format)

Parameters

format string

The format.

Returns

string

A string that represents this instance.

Operators

operator +(Vector4, Vector4)

Adds two vectors.

public static Vector4 operator +(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector to add.

right Vector4

The second vector to add.

Returns

Vector4

The sum of the two vectors.

operator /(Vector4, Vector4)

Divides the first vector by the second.

public static Vector4 operator /(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector.

right Vector4

The second vector.

Returns

Vector4

The vector resulting from the division.

operator /(Vector4, float)

Divides the specified vector by a specified scalar value.

public static Vector4 operator /(Vector4 value, float divisor)

Parameters

value Vector4

The vector.

divisor float

The scalar value.

Returns

Vector4

The vector that results from the division.

operator ==(Vector4, Vector4)

Tests for equality between two objects.

public static bool operator ==(Vector4 left, Vector4 right)

Parameters

left Vector4

The first value to compare.

right Vector4

The second value to compare.

Returns

bool

explicit operator Vector2(Vector4)

Performs an explicit conversion from Vector4 to Vector2.

public static explicit operator Vector2(Vector4 value)

Parameters

value Vector4

The value.

Returns

Vector2

The result of the conversion.

explicit operator Vector3(Vector4)

Performs an explicit conversion from Vector4 to Vector3.

public static explicit operator Vector3(Vector4 value)

Parameters

value Vector4

The value.

Returns

Vector3

The result of the conversion.

operator !=(Vector4, Vector4)

Tests for inequality between two objects.

public static bool operator !=(Vector4 left, Vector4 right)

Parameters

left Vector4

The first value to compare.

right Vector4

The second value to compare.

Returns

bool

operator *(Vector4, Vector4)

Modulates a vector with another by performing component-wise multiplication.

public static Vector4 operator *(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector to multiply.

right Vector4

The second vector to multiply.

Returns

Vector4

The multiplication of the two vectors.

operator *(Vector4, float)

Scales a vector by the given value.

public static Vector4 operator *(Vector4 value, float scale)

Parameters

value Vector4

The vector to scale.

scale float

The amount by which to scale the vector.

Returns

Vector4

The scaled vector.

operator *(float, Vector4)

Scales a vector by the given value.

public static Vector4 operator *(float scale, Vector4 value)

Parameters

scale float

The amount by which to scale the vector.

value Vector4

The vector to scale.

Returns

Vector4

The scaled vector.

operator -(Vector4, Vector4)

Subtracts two vectors.

public static Vector4 operator -(Vector4 left, Vector4 right)

Parameters

left Vector4

The first vector to subtract.

right Vector4

The second vector to subtract.

Returns

Vector4

The difference of the two vectors.

operator -(Vector4)

Reverses the direction of a given vector.

public static Vector4 operator -(Vector4 value)

Parameters

value Vector4

The vector to negate.

Returns

Vector4

A vector facing in the opposite direction.