ohsp

Prototype for a game with dual thruster controls.
git clone git://git.amin.space/ohsp.git
Log | Files | Refs | LICENSE

vector.h (922B)


      1 #ifndef VECTOR_H
      2 #define VECTOR_H
      3 
      4 #include <stdbool.h>
      5 #include <stdint.h>
      6 
      7 #ifndef M_PI
      8 #define M_PI 3.14159265358979f
      9 #endif
     10 
     11 struct Vec2d
     12 {
     13     union
     14     {
     15         struct
     16         {
     17             float x;
     18             float y;
     19         };
     20         struct
     21         {
     22             float w;
     23             float h;
     24         };
     25         float xy[2];
     26         float d[2];
     27     };
     28 };
     29 
     30 struct Vec2d vec2d_add(struct Vec2d v0, struct Vec2d v1);
     31 struct Vec2d vec2d_add_c(float x0, float y0, float x1, float y1);
     32 struct Vec2d vec2d_al_to_xy(struct Vec2d v);
     33 float vec2d_get_angle(float x, float y);
     34 bool vec2d_equal(struct Vec2d v0, struct Vec2d v1);
     35 float vec2d_get_length(float x, float y);
     36 struct Vec2d vec2d_negate(struct Vec2d v);
     37 struct Vec2d vec2d_normalize(float x, float y);
     38 struct Vec2d vec2d_scale(struct Vec2d v, float s);
     39 struct Vec2d vec2d_scale_c(float x, float y, float s);
     40 struct Vec2d vec2d_xy_to_al(struct Vec2d v);
     41 
     42 #endif