Difference between revisions of "Vector"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Outerbeast (talk | contribs) m  | 
				Outerbeast (talk | contribs)  m  | 
				||
| Line 4: | Line 4: | ||
{| class="wikitable"    | {| class="wikitable"    | ||
| − | |-  | + | |- style="font-weight:bold; text-align:center; vertical-align:middle;"  | 
! Function  | ! Function  | ||
| − | ! style="vertical-align:middle;"   | + | ! Description  | 
| − | + | |- style="vertical-align:middle; background-color:#F8F9FA; color:#202122;"  | |
| float DotProduct(const Vector2D& in lhs, const Vector2D& in rhs)  | | float DotProduct(const Vector2D& in lhs, const Vector2D& in rhs)  | ||
| − | + | | Returns a dot product of the given 2D vectors  | |
| − | |-  | + | |- style="background-color:#F8F9FA; color:#202122;"  | 
| − | | style="vertical-align:middle;"  | + | | style="vertical-align:middle;" | float DotProduct(const Vector& in lhs, const Vector& in rhs)  | 
| − | | float DotProduct(const Vector& in lhs, const Vector& in rhs)  | + | | Returns the dot product of the given vectors  | 
| − | + | |- style="background-color:#F8F9FA; color:#202122;"  | |
| − | |-  | ||
| − | |||
| Vector CrossProduct(const Vector& in, const Vector& in)  | | Vector CrossProduct(const Vector& in, const Vector& in)  | ||
| style="vertical-align:middle;" | Returns the cross product of the given vectors  | | style="vertical-align:middle;" | Returns the cross product of the given vectors  | ||
Revision as of 16:51, 14 February 2025
Vectors are essentially float arrays of size 3 which are used to represent various things like spatial co-ordinates, angles, velocities and colours, and so will come up very often.
Operations such as dot product and cross product can be performed on vectors using these global functions:
| Function | Description | 
|---|---|
| float DotProduct(const Vector2D& in lhs, const Vector2D& in rhs) | Returns a dot product of the given 2D vectors | 
| float DotProduct(const Vector& in lhs, const Vector& in rhs) | Returns the dot product of the given vectors | 
| Vector CrossProduct(const Vector& in, const Vector& in) | Returns the cross product of the given vectors | 
| Method | Description | 
|---|---|
| void Vector() | Default constructs a 3D vector (0, 0, 0) | 
| void Vector(const Vector& in vec) | Copy constructs a 3D vector | 
| void Vector(float x, float y, float z) | Constructs a 3D vector from 3 floats | 
| Vector& opAssign(const Vector& in other) | Assign vector | 
| Vector opNeg() const | Negate vector | 
| Vector opAdd(const Vector& in other) const | Add vectors | 
| Vector opSub(const Vector& in other) const | Subtract vectors | 
| Vector opMul(float fl) const | Multiply vector by value | 
| Vector opMul_r(float fl) const | Multiply vector by value | 
| Vector opDiv(float fl) const | Divide vector by value | 
| Vector opDiv_r(float fl) const | Divide vector by value | 
| float& opIndex(size_t uiIndex) | Index operator | 
| float opIndex(size_t uiIndex) const | Index operator | 
| bool opEquals(const Vector& in other) const | Compare vectors | 
| Vector opMul(const Vector& in other) const | Multiply vectors | 
| Vector opDiv(const Vector& in other) const | Divide vectors | 
| float Length() const | Gets the length of this vector | 
| float Length2D() const | Gets the length of this vector in 2D | 
| Vector Normalize() const | Returns the normalized form of this vector | 
| Vector2D Make2D() const | Returns the 2D form of this vector | 
| string ToString() const | Returns a string representation of this vector in the format "x, y, z" |