Physics utilities for cmdfx.
More...
Go to the source code of this file.
|
typedef struct CmdFX_Vector | CmdFX_Vector |
| A 2D Vector.
|
|
Physics utilities for cmdfx.
- Author
- Gregory Mitchell (me@gm.nosp@m.itch.nosp@m.215.x.nosp@m.yz)
- Version
- 0.1.1
- Date
- 2025-02-09
- Copyright
- Copyright (c) 2025
◆ Vector_add()
Adds two 2D Vectors.
- Parameters
-
v1 | The first 2D Vector. |
v2 | The second 2D Vector. |
- Returns
- The sum of the two 2D Vectors.
◆ Vector_addAll()
Adds multiple 2D Vectors.
- Parameters
-
vectors | The 2D Vectors. |
count | The number of 2D Vectors. |
- Returns
- The sum of the 2D Vectors.
◆ Vector_create()
Creates a new 2D Vector.
This method creates a new 2D Vector with the given x and y coordinates. The vector must be freed with free
when it is no longer needed.
- Parameters
-
x | The x coordinate. |
y | The y coordinate. |
- Returns
- The new 2D Vector.
◆ Vector_divide()
Divides a 2D Vector by a scalar.
- Parameters
-
v | The 2D Vector. |
scalar | The scalar. |
- Returns
- 0 if successful, -1 if an error occurred.
◆ Vector_dot()
Multiplies a 2D Vector by a scalar.
- Parameters
-
v | The 2D Vector. |
scalar | The scalar. |
- Returns
- The product of the 2D Vector and the scalar.
◆ Vector_flip()
Flips a 2D Vector.
- Parameters
-
- Returns
- 0 if successful, -1 if an error occurred.
◆ Vector_flipX()
Flips a 2D Vector horizontally.
- Parameters
-
- Returns
- 0 if successful, -1 if an error occurred.
◆ Vector_flipY()
Flips a 2D Vector vertically.
- Parameters
-
- Returns
- 0 if successful, -1 if an error occurred.
◆ Vector_getAngle()
Gets the angle of a 2D Vector.
- Parameters
-
- Returns
- The angle of the 2D Vector, in radians.
◆ Vector_getMagnitude()
Gets the magnitude of a 2D Vector.
- Parameters
-
- Returns
- The magnitude of the 2D Vector.
◆ Vector_multiply()
Multiplies a 2D Vector by a scalar.
- Parameters
-
v | The 2D Vector. |
scalar | The scalar. |
- Returns
- 0 if successful, -1 if an error occurred.
◆ Vector_rotate()
Rotates a 2D Vector by a specific number of radians.
This method rotates a 2D Vector by a specific number of radians. The rotation will be done around the origin.
- Parameters
-
v | The 2D Vector. |
radians | The number of radians to rotate. |
- Returns
- 0 if successful, -1 if an error occurred.
◆ Vector_subtract()
Subtracts two 2D Vectors.
- Parameters
-
v1 | The first 2D Vector. |
v2 | The second 2D Vector. |
- Returns
- The difference of the two 2D Vectors.