Class Vec3
Represents a 3D vector for coordinates.
Inherited Members
Namespace: Genesis.Math
Assembly: Genesis.dll
Syntax
public class Vec3
Constructors
Vec3(vec3)
Creates a new 3D vector with specified coordinates from a glm vec3 object.
Declaration
public Vec3(vec3 vec3)
Parameters
Type | Name | Description |
---|---|---|
vec3 | vec3 |
Vec3(Point)
Creates a new 3D vector with specified coordinates from a Point object.
Declaration
public Vec3(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point |
Vec3(PointF)
Creates a new 3D vector with specified coordinates from a PointF object.
Declaration
public Vec3(PointF point)
Parameters
Type | Name | Description |
---|---|---|
PointF | point |
Vec3(Size)
Creates a new 3D vector with specified coordinates from a Size object.
Declaration
public Vec3(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size | The Size object to extract coordinates from. |
Vec3(SizeF)
Creates a new 3D vector with specified coordinates from a SizeF object.
Declaration
public Vec3(SizeF size)
Parameters
Type | Name | Description |
---|---|---|
SizeF | size | The SizeF object to extract coordinates from. |
Vec3(float)
Creates a new Vector
Declaration
public Vec3(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value |
Vec3(float, float)
Creates a new Vector
Declaration
public Vec3(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | |
float | y |
Vec3(float, float, float)
Creates a new 3D vector with 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. |
Properties
X
Gets or sets the X-coordinate of the vector.
Declaration
public float X { get; set; }
Property Value
Type | Description |
---|---|
float |
Y
Gets or sets the Y-coordinate of the vector.
Declaration
public float Y { get; set; }
Property Value
Type | Description |
---|---|
float |
Z
Gets or sets the Z-coordinate of the vector.
Declaration
public float Z { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
Add(Vec3)
Adds the value from a vector
Declaration
public void Add(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec |
Add(float, float)
Adds the values to the vector
Declaration
public void Add(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | |
float | y |
Add(float, float, float)
Adds the values to the vector
Declaration
public void Add(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | |
float | y | |
float | z |
AddX(float)
Add the value to the X param
Declaration
public void AddX(float x)
Parameters
Type | Name | Description |
---|---|---|
float | x |
AddY(float)
Add the value to the y param
Declaration
public void AddY(float y)
Parameters
Type | Name | Description |
---|---|---|
float | y |
AddZ(float)
Add the value to the z param
Declaration
public void AddZ(float z)
Parameters
Type | Name | Description |
---|---|---|
float | z |
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)
Returns the offset angle to the vector.
Declaration
public float Degres(Vec3 vec3)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec3 | The reference vector. |
Returns
Type | Description |
---|---|
float | The offset angle to the vector in degrees. |
Degres(float, float)
Returns the offset angle to the vector.
Declaration
public float Degres(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | The X-coordinate of the vector. |
float | y | The Y-coordinate of the vector. |
Returns
Type | Description |
---|---|
float | The offset angle to the vector in degrees. |
Distance(Vec3)
Returns the distance between two vectors
Declaration
public float Distance(Vec3 vec3)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec3 |
Returns
Type | Description |
---|---|
float |
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
Declaration
public Vec3 Forward(Vec3 rotation, float dist)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | rotation | |
float | dist |
Returns
Type | Description |
---|---|
Vec3 |
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. |
Normalize()
Normalizes the vector.
Declaration
public Vec3 Normalize()
Returns
Type | Description |
---|---|
Vec3 | A normalized Vec3 instance. |
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 value for the vector
Declaration
public void Set(Vec3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec |
Set(float, float, float)
Sets the value for the vector
Declaration
public void Set(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | |
float | y | |
float | z |
Sub(Vec3)
Subtract the vector
Declaration
public void Sub(Vec3 v)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | v |
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 vector towards in 3D.
Declaration
public Vec3 Towards(float degrees, float dist)
Parameters
Type | Name | Description |
---|---|---|
float | degrees | |
float | dist | The distance. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the vector towards in 3D. |
Towards2D(float, Vec3, float)
Returns a new vector towards the given direction.
Declaration
public static Vec3 Towards2D(float degrees, Vec3 start, float dist)
Parameters
Type | Name | Description |
---|---|---|
float | degrees | |
Vec3 | start | |
float | dist |
Returns
Type | Description |
---|---|
Vec3 |
Towards3D(Vec3, Vec3, float)
Calculates the Vector towards in 3D
Declaration
public static Vec3 Towards3D(Vec3 rotation, Vec3 start, float dist)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | rotation | |
Vec3 | start | |
float | dist |
Returns
Type | Description |
---|---|
Vec3 |
Towards3D(float, float, float, Vec3, float)
Calculates the towards vector
Declaration
public static Vec3 Towards3D(float rotX, float rotY, float rotZ, Vec3 start, float dist)
Parameters
Type | Name | Description |
---|---|---|
float | rotX | |
float | rotY | |
float | rotZ | |
Vec3 | start | |
float | dist |
Returns
Type | Description |
---|---|
Vec3 |
Zero()
Returns a new 3D vector with X = 0, Y = 0, Z = 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)
Add operator for vector substraction.
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 substraction. |
operator *(Vec3, Vec3)
Add operator for vector multiplication.
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 value.
Declaration
public static Vec3 operator *(Vec3 vec, float value)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | vec | The vector to multiply. |
float | value | The scalar value. |
Returns
Type | Description |
---|---|
Vec3 | A new Vec3 instance representing the result of the multiplication. |
operator -(Vec3, Vec3)
Subtracts one vector from another.
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 the subtraction. |