Struct Vec3
Represents a three-dimensional vector, used for representing points or directions in 3D space.
Inherited Members
Namespace: Genesis.Math
Assembly: Genesis.dll
Syntax
public struct Vec3
Constructors
Vec3(vec3)
Initializes a new instance of the Vec3 struct from a glm.vec3 object.
Declaration
public Vec3(vec3 vec3)
Parameters
Type | Name | Description |
---|---|---|
vec3 | vec3 | The glm.vec3 object to extract coordinates from. |
Vec3(Point)
Declaration
public Vec3(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point | The Point object to extract coordinates from. |
Vec3(PointF)
Declaration
public Vec3(PointF point)
Parameters
Type | Name | Description |
---|---|---|
PointF | point | The PointF object to extract coordinates from. |
Vec3(Size)
Declaration
public Vec3(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size | The Size object to extract coordinates from. |
Vec3(SizeF)
Declaration
public Vec3(SizeF size)
Parameters
Type | Name | Description |
---|---|---|
SizeF | size | The SizeF object to extract coordinates from. |
Vec3(float)
Initializes a new instance of the Vec3 struct with all coordinates set to the same value.
Declaration
public Vec3(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | The value to assign to all coordinates of the vector. |
Vec3(float, float)
Initializes a new instance of the Vec3 struct with the specified X and Y coordinates, and Z set to 0.
Declaration
public Vec3(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | The X-coordinate of the vector. |
float | y | The Y-coordinate of the vector. |
Vec3(float, float, float)
Initializes a new instance of the Vec3 struct with the specified coordinates.
Declaration
public Vec3(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The X-coordinate of the vector. |
float | y | The Y-coordinate of the vector. |
float | z | The Z-coordinate of the vector. |
Fields
X
Gets or sets the X-coordinate of the vector.
Declaration
public float X
Field Value
Type | Description |
---|---|
float |
Y
Gets or sets the Y-coordinate of the vector.
Declaration
public float Y
Field Value
Type | Description |
---|---|
float |
Z
Gets or sets the Z-coordinate of the vector.
Declaration
public float Z
Field Value
Type | Description |
---|---|
float |
Methods
Add(Vec3)
Adds the value from another vector.
Declaration
public Vec3 Add(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The vector to add. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 that is the sum of this vector and the specified vector. |
Add(float, float)
Adds the specified X and Y values to this vector.
Declaration
public Vec3 Add(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | The value to add to the X component. |
float | y | The value to add to the Y component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the added values. |
Add(float, float, float)
Adds the specified X, Y, and Z values to this vector.
Declaration
public Vec3 Add(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The value to add to the X component. |
float | y | The value to add to the Y component. |
float | z | The value to add to the Z component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the added values. |
AddX(float)
Adds the specified value to the X component of this vector.
Declaration
public Vec3 AddX(float x)
Parameters
Type | Name | Description |
---|---|---|
float | x | The value to add to the X component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated X component. |
AddY(float)
Adds the specified value to the Y component of this vector.
Declaration
public Vec3 AddY(float y)
Parameters
Type | Name | Description |
---|---|---|
float | y | The value to add to the Y component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated Y component. |
AddZ(float)
Adds the specified value to the Z component of this vector.
Declaration
public Vec3 AddZ(float z)
Parameters
Type | Name | Description |
---|---|---|
float | z | The value to add to the Z component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated Z component. |
Ceiling(Vec3)
Returns a new Vec3 object where each component is the smallest integer greater than or equal to the corresponding component of the input Vec3.
Declaration
public static Vec3 Ceiling(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The input Vec3 to be processed. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with each component rounded up to the nearest integer. |
Cross(Vec3, Vec3)
Calculates the cross product of two vectors.
Declaration
public static Vec3 Cross(Vec3 vec1, Vec3 vec2)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec1 | The first vector. |
Vec3 | vec2 | The second vector. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the cross product of the two vectors. |
Degres(Vec3)
Calculates the angle in degrees from this vector to the specified vector.
Declaration
public float Degres(Vec3 vec3)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec3 | The reference vector. |
Returns
Type | Description |
---|---|
float | The angle in degrees from this vector to the specified vector. |
Degres(float, float)
Calculates the angle in degrees from this vector to the specified coordinates.
Declaration
public float Degres(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | The X-coordinate of the target point. |
float | y | The Y-coordinate of the target point. |
Returns
Type | Description |
---|---|
float | The angle in degrees from this vector to the specified point. |
Distance(Vec3)
Calculates the distance between this vector and another vector.
Declaration
public float Distance(Vec3 vec3)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec3 | The vector to measure distance to. |
Returns
Type | Description |
---|---|
float | The distance between this vector and the specified vector. |
Dot(Vec3, Vec3)
Calculates the dot product of two vectors.
Declaration
public static float Dot(Vec3 vec1, Vec3 vec2)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec1 | The first vector. |
Vec3 | vec2 | The second vector. |
Returns
Type | Description |
---|---|
float | The dot product of the two vectors. |
Floor(Vec3)
Returns a new Vec3 object where each component is rounded down to the nearest integer
Declaration
public static Vec3 Floor(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The input Vec3 to be processed. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with each component rounded down to the nearest integer. |
Forward(Vec3, float)
Returns the forward vector based on the specified rotation and distance.
Declaration
public Vec3 Forward(Vec3 rotation, float dist)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | rotation | The rotation to apply. |
float | dist | The distance to project forward. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 representing the forward vector. |
Half()
Returns a new Vec3 instance with the components of this instance halved.
Declaration
public Vec3 Half()
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance with the components halved. |
Half(Vec3)
Returns a new Vec3 instance with each component halved.
Declaration
public static Vec3 Half(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The Vec3 instance to halve. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance with each component halved. |
Length()
Returns the vector length
Declaration
public float Length()
Returns
Type | Description |
---|---|
float |
Normalize()
Normalizes the vector.
Declaration
public Vec3 Normalize()
Returns
Type | Description |
---|---|
Vec3 | A normalized Vec3 instance. |
NormalizeAngles(Vec3)
Declaration
public static Vec3 NormalizeAngles(Vec3 value)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | value |
Returns
Type | Description |
---|---|
Vec3 |
NormalizeAngles(float, float, float)
Declaration
public static Vec3 NormalizeAngles(float vX, float vY, float vZ)
Parameters
Type | Name | Description |
---|---|---|
float | vX | |
float | vY | |
float | vZ |
Returns
Type | Description |
---|---|
Vec3 |
Normalized(Vec3)
Returns a normalized version of the input vector.
Declaration
public static Vec3 Normalized(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The vector to normalize. |
Returns
Type | Description |
---|---|
Vec3 | A normalized Vec3 instance. |
Random(Vec3, Vec3)
Generates an rendom vector from min an max value
Declaration
public static Vec3 Random(Vec3 min, Vec3 max)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | min | The min vector |
Vec3 | max | The max vector |
Returns
Type | Description |
---|---|
Vec3 |
Random(Vec3, Vec3, int)
Generates an rendom vector from min an max value with the given seed
Declaration
public static Vec3 Random(Vec3 min, Vec3 max, int seed)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | min | The min vector |
Vec3 | max | The max vector |
int | seed | The seed |
Returns
Type | Description |
---|---|
Vec3 |
Round(Vec3)
Returns a new Vec3 object where each component is rounded to the nearest integer
Declaration
public static Vec3 Round(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The input Vec3 to be processed. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with each component rounded to the nearest integer. |
Set(Vec3)
Sets the values for the vector based on another vector.
Declaration
public Vec3 Set(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The vector to copy values from. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with values copied from the specified vector. |
Set(float, float, float)
Sets the values for the vector.
Declaration
public Vec3 Set(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The value to set the X component to. |
float | y | The value to set the Y component to. |
float | z | The value to set the Z component to. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the specified values. |
SetX(float)
Sets the X component of the vector to the specified value.
Declaration
public Vec3 SetX(float x)
Parameters
Type | Name | Description |
---|---|---|
float | x | The value to set the X component to. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated X component. |
SetY(float)
Sets the Y component of the vector to the specified value.
Declaration
public Vec3 SetY(float y)
Parameters
Type | Name | Description |
---|---|---|
float | y | The value to set the Y component to. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated Y component. |
SetZ(float)
Sets the Z component of the vector to the specified value.
Declaration
public Vec3 SetZ(float z)
Parameters
Type | Name | Description |
---|---|---|
float | z | The value to set the Z component to. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated Z component. |
Sub(Vec3)
Subtracts the specified vector from this vector.
Declaration
public Vec3 Sub(Vec3 v)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | v | The vector to subtract. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 that is the result of the subtraction. |
SubX(float)
Subtracts the specified value from the X component of this vector.
Declaration
public Vec3 SubX(float x)
Parameters
Type | Name | Description |
---|---|---|
float | x | The value to subtract from the X component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated X component. |
SubY(float)
Subtracts the specified value from the Y component of this vector.
Declaration
public Vec3 SubY(float y)
Parameters
Type | Name | Description |
---|---|---|
float | y | The value to subtract from the Y component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated Y component. |
SubZ(float)
Subtracts the specified value from the Z component of this vector.
Declaration
public Vec3 SubZ(float z)
Parameters
Type | Name | Description |
---|---|---|
float | z | The value to subtract from the Z component. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 with the updated Z component. |
ToBulletVec3()
Converts the vector to its BulletSharp equivalent.
Declaration
public Vector3 ToBulletVec3()
Returns
Type | Description |
---|---|
Vector3 | A BulletSharp Vector3 instance representing the same vector. |
ToGlmVec3()
Converts the vector to its GLM equivalent.
Declaration
public vec3 ToGlmVec3()
Returns
Type | Description |
---|---|
vec3 | A GLM vec3 instance representing the same vector. |
ToString()
Returns a string representation of the vector.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string containing the X, Y, and Z coordinates of the vector. |
Overrides
Towards(float, float)
Calculates the point in 3D space towards a specified angle and distance from this vector.
Declaration
public Vec3 Towards(float degrees, float dist)
Parameters
Type | Name | Description |
---|---|---|
float | degrees | The angle in degrees. |
float | dist | The distance from this vector. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the calculated point in 3D space. |
Towards2D(float, Vec3, float)
Returns a new vector in 2D space towards a specified angle from the given starting vector.
Declaration
public static Vec3 Towards2D(float degrees, Vec3 start, float dist)
Parameters
Type | Name | Description |
---|---|---|
float | degrees | The angle in degrees. |
Vec3 | start | The starting vector. |
float | dist | The distance from the starting vector. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the target vector in 2D space. |
Towards3D(Vec3, Vec3, float)
Calculates a point in 3D space towards the specified rotation from a starting vector.
Declaration
public static Vec3 Towards3D(Vec3 rotation, Vec3 start, float dist)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | rotation | The rotation vector representing angles. |
Vec3 | start | The starting vector. |
float | dist | The distance from the starting vector. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the calculated point in 3D space. |
Towards3D(float, float, float, Vec3, float)
Calculates a point in 3D space towards the specified rotation angles from a starting vector.
Declaration
public static Vec3 Towards3D(float rotX, float rotY, float rotZ, Vec3 start, float dist)
Parameters
Type | Name | Description |
---|---|---|
float | rotX | The rotation angle around the X-axis. |
float | rotY | The rotation angle around the Y-axis. |
float | rotZ | The rotation angle around the Z-axis. |
Vec3 | start | The starting vector. |
float | dist | The distance from the starting vector. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the calculated point in 3D space. |
Zero()
Returns a new vector representing the origin (0, 0, 0).
Declaration
public static Vec3 Zero()
Returns
Type | Description |
---|---|
Vec3 | A Vec3 instance representing the zero vector. |
Operators
operator +(Vec3, Vec3)
Add operator for vector addition.
Declaration
public static Vec3 operator +(Vec3 vec1, Vec3 vec2)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec1 | The first vector. |
Vec3 | vec2 | The second vector. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the result of vector addition. |
operator /(Vec3, Vec3)
Divide operator for vector division by another vector.
Declaration
public static Vec3 operator /(Vec3 vec1, Vec3 vec2)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec1 | The first vector. |
Vec3 | vec2 | The second vector to divide by. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the result of vector division. |
operator *(Vec3, Vec3)
Multiply operator for vector multiplication with another vector.
Declaration
public static Vec3 operator *(Vec3 vec1, Vec3 vec2)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec1 | The first vector. |
Vec3 | vec2 | The second vector. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the result of vector multiplication. |
operator *(Vec3, float)
Multiplies the vector by a scalar.
Declaration
public static Vec3 operator *(Vec3 vec, float value)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The vector to multiply. |
float | value | The scalar to multiply by. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the scaled vector. |
operator -(Vec3, Vec3)
Subtract operator for vector subtraction.
Declaration
public static Vec3 operator -(Vec3 vec1, Vec3 vec2)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec1 | The first vector. |
Vec3 | vec2 | The second vector to subtract. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the result of vector subtraction. |