#include "../_math.h"
#include <stddef.h>
#include <string.h>
#include "../str.h"
Go to the source code of this file.
◆ gm3_pos_cross
| #define gm3_pos_cross |
( |
| a, |
|
|
| b ) |
Value: ((
gm3Pos){(a).y * (b).z - (a).z * (b).y, (a).z * (b).x - (a).x * (b).z, \
(a).x * (b).y - (a).y * (b).x})
Represents a 3D position or vector.
Definition position.h:11
Calculates the cross product of two gm3Pos vectors (a x b).
- Parameters
-
- Returns
- A new gm3Pos vector representing the cross product.
◆ gm3_pos_distance
| #define gm3_pos_distance |
( |
| a, |
|
|
| b ) |
Value: sqrt(
pow((a).x - (b).x, 2) +
pow((a).y - (b).y, 2) +
pow((a).z - (b).z, 2))
double pow(double base, double exp)
Calculates the base raised to the power of the exponent (base^exp).
Definition math.h:358
double sqrt(double x)
Calculates the square root of x.
Definition math.h:339
Calculates the Euclidean distance between two gm3Pos points.
- Parameters
-
- Returns
- The distance between the two points.
◆ gm3_pos_dot
| #define gm3_pos_dot |
( |
| a, |
|
|
| b ) |
Value:((a).x * (b).x + (a).y * (b).y + (a).z * (b).z)
Calculates the dot product of two gm3Pos vectors.
- Parameters
-
- Returns
- The dot product (scalar value).
◆ gm3_pos_from2
| #define gm3_pos_from2 |
( |
| p, |
|
|
| z ) |
Value:
#define gm3pos(x, y, z)
Creates a new gm3Pos struct with the given coordinates.
Definition position.h:22
Creates a gm3Pos from a 2D gmPos and a Z-coordinate.
- Parameters
-
| p | The 2D gmPos. |
| z | The Z-coordinate. |
- Returns
- A new gm3Pos instance.
◆ gm3_pos_magnitude
| #define gm3_pos_magnitude |
( |
| p | ) |
|
Value:sqrt((p).x *(p).x + (p).y * (p).y + (p).z * (p).z)
Calculates the magnitude (length) of a gm3Pos vector.
- Parameters
-
- Returns
- The magnitude of the vector.
◆ gm3_pos_project_simple
| #define gm3_pos_project_simple |
( |
| p | ) |
|
Value:gmpos((p).x / (p).z, (p).y / (p).z)
Performs a simple perspective projection of a 3D point onto a 2D plane.
This macro assumes a camera at the origin looking down the Z-axis, and projects the point onto the Z=1 plane.
- Parameters
-
- Returns
- A gmPos representing the 2D projected coordinates.
◆ gm3_pos_reset
| #define gm3_pos_reset |
( |
| p | ) |
|
Value:
Resets the coordinates of a gm3Pos struct to (0, 0, 0).
- Parameters
-
| p | A pointer to the gm3Pos struct to reset. |
◆ gm3pos
| #define gm3pos |
( |
| x, |
|
|
| y, |
|
|
| z ) |
Value:
Creates a new gm3Pos struct with the given coordinates.
- Parameters
-
| x | The X-coordinate. |
| y | The Y-coordinate. |
| z | The Z-coordinate. |
- Returns
- A new gm3Pos instance.
◆ gm3_pos_mul()
Multiplies the components of a gm3Pos vector by the corresponding components of another gm3Pos vector (component-wise multiplication).
- Parameters
-
| res | A pointer to the gm3Pos vector to modify (result stored here). |
| trans | The gm3Pos vector to multiply by. |
◆ gm3_pos_mul_scalar()
| void gm3_pos_mul_scalar |
( |
gm3Pos * | res, |
|
|
double | s ) |
Multiplies the components of a gm3Pos vector by a scalar value.
- Parameters
-
| res | A pointer to the gm3Pos vector to modify (result stored here). |
| s | The scalar value to multiply by. |
◆ gmg_pos3()
Converts a gm3Pos struct to a string representation for debugging.
- Parameters
-
| str | A pointer to a gmStr buffer to append the string to. |
| pos | The gm3Pos struct to convert. |
- Returns
- 0 on success.