|
PER Firmware
|
2D vector types and operations. More...
#include <math.h>Go to the source code of this file.
Classes | |
| struct | vector2 |
Typedefs | |
| typedef struct vector2 | vector2_t |
Functions | |
| static vector2_t | vector2_add (const vector2_t a, const vector2_t b) |
| Add two 2D vectors. | |
| static vector2_t | vector2_sub (const vector2_t a, const vector2_t b) |
| Subtract one 2D vector from another. | |
| static vector2_t | vector2_scale (const vector2_t vec, const float scalar) |
| Scale a 2D vector by a scalar. | |
| static float | vector2_dot (const vector2_t a, const vector2_t b) |
| Dot product of two 2D vectors. | |
| static float | vector2_cross (const vector2_t a, const vector2_t b) |
| Cross product of two 2D vectors. | |
| static float | vector2_magnitude (const vector2_t vec) |
| Calculate the magnitude of a 2D vector. | |
| static vector2_t | vector2_normalize (const vector2_t vec) |
| Normalize a 2D vector. | |
| static float | vector2_distance (const vector2_t a, const vector2_t b) |
| Distance between two 2D points. | |
| static vector2_t | vector2_midpoint (const vector2_t a, const vector2_t b) |
| Midpoint of two 2D points. | |
| static vector2_t | vector2_perpendicular (const vector2_t vec) |
| Rotate a 2D vector 90 degrees counterclockwise. | |
2D vector types and operations.
Basic floating point 2D vector operations.
Add two 2D vectors.
| a | The first input vector |
| b | The second input vector |
Cross product of two 2D vectors.
In 2D the cross product has only a Z component, so it reduces to a scalar. Positive means b lies counterclockwise of a, negative means clockwise.
| a | The first input vector |
| b | The second input vector |
Distance between two 2D points.
| a | The first point |
| b | The second point |
Dot product of two 2D vectors.
| a | The first input vector |
| b | The second input vector |
|
inlinestatic |
Calculate the magnitude of a 2D vector.
| vec | The input vector |
Midpoint of two 2D points.
| a | The first point |
| b | The second point |
Normalize a 2D vector.
| vec | The input vector |
Rotate a 2D vector 90 degrees counterclockwise.
| vec | The input vector |
Scale a 2D vector by a scalar.
| vec | The input vector |
| scalar | The value to scale by |