PowerBlocks SDK
 
Loading...
Searching...
No Matches
vec2.h File Reference

Simple 2D vectors. More...

#include <math.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  vec2i
 
struct  vec2s16
 
struct  vec2
 

Macros

#define vec2i_new(x, y)
 
#define vec2s16_new(x, y)
 
#define vec2_new(x, y)
 
#define vec2_add(a, b)
 
#define vec2_sub(a, b)
 
#define vec2_dot(a, b)
 
#define vec2_magnitude_sq(a)
 
#define vec2_magnitude(a)
 
#define vec2_muls(a, s)
 
#define vec2_divs(a, s)
 
#define vec2i_add(a, b)
 
#define vec2i_sub(a, b)
 
#define vec2i_dot(a, b)
 
#define vec2i_magnitude_sq(a)
 
#define vec2i_magnitude(a)
 
#define vec2i_muls(a, s)
 
#define vec2i_divs(a, s)
 
#define vec2s16_add(a, b)
 
#define vec2s16_sub(a, b)
 
#define vec2s16_dot(a, b)
 
#define vec2s16_magnitude_sq(a)
 
#define vec2s16_magnitude(a)
 
#define vec2s16_muls(a, s)
 
#define vec2s16_divs(a, s)
 

Detailed Description

Simple 2D vectors.

Provides helper functions and data structures for 2D vectors.

Author
Samuel Fitzsimons (rainbain)
Date
2025 @license MIT (see LICENSE file)

Macro Definition Documentation

◆ vec2_add

#define vec2_add ( a,
b )
Value:
((vec2){(a).x+(b).x, (a).y+(b).y})
Definition vec2.h:27

◆ vec2_divs

#define vec2_divs ( a,
s )
Value:
((vec2){(a).x/s, (a).y/s})

◆ vec2_dot

#define vec2_dot ( a,
b )
Value:
((a).x * (b).x + (a).y * (b).y)

◆ vec2_magnitude

#define vec2_magnitude ( a)
Value:
(sqrtf(vec2_magnitude_sq(a)))

◆ vec2_magnitude_sq

#define vec2_magnitude_sq ( a)
Value:
vec2_dot(a, a)

◆ vec2_muls

#define vec2_muls ( a,
s )
Value:
((vec2){(a).x*s, (a).y*s})

◆ vec2_new

#define vec2_new ( x,
y )
Value:
((vec2){x, y})

◆ vec2_sub

#define vec2_sub ( a,
b )
Value:
((vec2){(a).x-(b).x, (a).y-(b).y})

◆ vec2i_add

#define vec2i_add ( a,
b )
Value:
((vec2i){(a).x+(b).x, (a).y+(b).y})
Definition vec2.h:17

◆ vec2i_divs

#define vec2i_divs ( a,
s )
Value:
((vec2i){(a).x/s, (a).y/s})

◆ vec2i_dot

#define vec2i_dot ( a,
b )
Value:
((a).x * (b).x + (a).y * (b).y)

◆ vec2i_magnitude

#define vec2i_magnitude ( a)
Value:
(sqrtf(vec2_magnitude_sq(a)))

◆ vec2i_magnitude_sq

#define vec2i_magnitude_sq ( a)
Value:
vec2_dot(a, a)

◆ vec2i_muls

#define vec2i_muls ( a,
s )
Value:
((vec2i){(a).x*s, (a).y*s})

◆ vec2i_new

#define vec2i_new ( x,
y )
Value:
((vec2i){x, y})

◆ vec2i_sub

#define vec2i_sub ( a,
b )
Value:
((vec2i){(a).x-(b).x, (a).y-(b).y})

◆ vec2s16_add

#define vec2s16_add ( a,
b )
Value:
((vec2s16){(a).x+(b).x, (a).y+(b).y})
Definition vec2.h:22

◆ vec2s16_divs

#define vec2s16_divs ( a,
s )
Value:
((vec2s16){(a).x/s, (a).y/s})

◆ vec2s16_dot

#define vec2s16_dot ( a,
b )
Value:
((a).x * (b).x + (a).y * (b).y)

◆ vec2s16_magnitude

#define vec2s16_magnitude ( a)
Value:
(sqrtf(vec2_magnitude_sq(a)))

◆ vec2s16_magnitude_sq

#define vec2s16_magnitude_sq ( a)
Value:
vec2_dot(a, a)

◆ vec2s16_muls

#define vec2s16_muls ( a,
s )
Value:
((vec2s16){(a).x*s, (a).y*s})

◆ vec2s16_new

#define vec2s16_new ( x,
y )
Value:
((vec2s16){x, y})

◆ vec2s16_sub

#define vec2s16_sub ( a,
b )
Value:
((vec2s16){(a).x-(b).x, (a).y-(b).y})