#include "trc_world_position.h"
#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
◆ DEG_TO_RAD
| #define DEG_TO_RAD |
( |
|
angleInDegrees | ) |
(adjust_angle((angleInDegrees) * PI / 180.0)) |
Angle in degrees to angle in radians
◆ DEGREE
◆ DOWN_DIR
| #define DOWN_DIR (3 * (UP_DIR)) |
270 degrees, or the angle in radians for ↓
◆ LEFT_DIR
180 degrees, or the angle in radians for ←
◆ PI
◆ PRECISION
To compare doubles and floats
◆ RAD_TO_DEG
| #define RAD_TO_DEG |
( |
|
angleInRadians | ) |
(adjust_angle(angleInRadians) * 180.0 / PI) |
Angle in radians to angle in degrees
◆ RIGHT_DIR
| #define RIGHT_DIR (PI * 0) |
0 degrees, or the angle in radians for →
◆ trc_world_position_to_string
Only for debug, it returns the position in the form of a string with the format:
"pos_name = (pos.x, pos.y)"
- Note
- Caller MUST free the memory allocated for the string
◆ UP_DIR
90 degrees, or the angle in radians for ↑
◆ adjust_angle()
| float adjust_angle |
( |
const float |
angle | ) |
|
Returns the angle so it's in the range of 0 to 2*PI
- Parameters
-
| angle | The angle to adjust, in radians |
◆ angle_from_vector()
Use the position given as a vector, and returns it's angle
◆ are_equals()
| bool are_equals |
( |
const float |
f1, |
|
|
const float |
f2 |
|
) |
| |
Returns if the first float is equal to the second
- Parameters
-
| f1 | First float |
| f2 | Second float |
◆ distance_between()
Returns the distance between p1 and p2
- Parameters
-
| p1 | First point |
| p2 | Second point |
◆ normalize_vector()
Returns the normalized vector
- Note
- If it is already normalized, returns one with the same parameters
◆ scalar_multiplication()
Returns the given vector scaled by the given factor
◆ trc_world_position_to_string_with_name()
| char * trc_world_position_to_string_with_name |
( |
const trc_world_position_t |
pos, |
|
|
const char * |
pos_name |
|
) |
| |
- Note
- Remember to free the memory allocated for the string!
◆ vector_length()
Returns the distance between the origin and the given vector