src/math/extrema.h
src/math/mat3x3.h
src/math/pi.h
- src/math/point.h
+ src/math/vec.h
src/math/rand.c
src/math/rand.h
src/math/rect.c
#include "color.h"
#include "game/sprite_font.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "math/rect.h"
#include "math/triangle.h"
#ifndef LABELS_H_
#define LABELS_H_
-#include "math/point.h"
+#include "math/vec.h"
#include "color.h"
#include "ebisp/expr.h"
#include "system/lt.h"
#include "system/str.h"
#include "system/log.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "label_layer.h"
#include "dynarray.h"
#include "color.h"
#include "layer.h"
#include "color.h"
-#include "math/point.h"
+#include "math/vec.h"
#define LABELS_SIZE vec(2.0f, 2.0f)
#define LABEL_LAYER_ID_MAX_SIZE 36
#ifndef POINT_LAYER_H_
#define POINT_LAYER_H_
-#include "math/point.h"
+#include "math/vec.h"
#include "color.h"
#include "layer.h"
#include "game/level/script.h"
#include "game/level/rigid_bodies.h"
#include "goals.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "platforms.h"
#include "player.h"
#include "system/line_stream.h"
#ifndef SOUND_SAMPLES_H_
#define SOUND_SAMPLES_H_
-#include "math/point.h"
+#include "math/vec.h"
typedef struct Sound_samples Sound_samples;
#define SPRITE_FONT_H_
#include "color.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "math/rect.h"
#define FONT_CHAR_WIDTH 7
#include "game/sound_samples.h"
#include "game/sprite_font.h"
#include "math/extrema.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "sdl/renderer.h"
#include "system/log.h"
#include "system/lt.h"
#ifndef MAT3X3_H_
#define MAT3X3_H_
-#include "point.h"
+#include "vec.h"
typedef struct mat3x3 {
float M[3][3];
+++ /dev/null
-#ifndef POINT_H_
-#define POINT_H_
-
-#include "math/pi.h"
-
-typedef struct Point {
- float x, y;
-} Point;
-
-typedef Point Vec;
-
-static inline
-Vec vec(float x, float y)
-{
- Vec result = {
- .x = x,
- .y = y
- };
- return result;
-}
-
-static inline
-Vec vec_scala_mult(Vec v, float scalar)
-{
- Vec result = {
- .x = v.x * scalar,
- .y = v.y * scalar
- };
- return result;
-}
-
-static inline
-Vec vec_from_polar(float arg, float mag)
-{
- return vec_scala_mult(
- vec(cosf(arg), sinf(arg)),
- mag);
-}
-
-static inline
-Vec vec_from_ps(Point p1, Point p2)
-{
- Vec result = {
- .x = p2.x - p1.x,
- .y = p2.y - p1.y
- };
- return result;
-}
-
-static inline
-float vec_arg(Vec v)
-{
- return atan2f(v.y, v.x);
-}
-
-static inline
-float vec_mag(Vec v)
-{
- return sqrtf(v.x * v.x + v.y * v.y);
-}
-
-static inline
-Vec vec_sum(Vec v1, Vec v2)
-{
- Vec result = {
- .x = v1.x + v2.x,
- .y = v1.y + v2.y
- };
- return result;
-}
-
-static inline
-Vec vec_sub(Vec v1, Vec v2)
-{
- Vec result = {
- .x = v1.x - v2.x,
- .y = v1.y - v2.y
- };
- return result;
-}
-
-static inline
-Vec vec_neg(Vec v)
-{
- Vec result = {
- .x = -v.x,
- .y = -v.y
- };
-
- return result;
-}
-
-static inline
-float vec_length(Vec v)
-{
- return sqrtf(v.x * v.x + v.y * v.y);
-}
-
-static inline
-void vec_add(Vec *v1, Vec v2)
-{
- v1->x += v2.x;
- v1->y += v2.y;
-}
-
-static inline
-Vec vec_entry_mult(Vec v1, Vec v2)
-{
- Vec result = {
- .x = v1.x * v2.x,
- .y = v1.y * v2.y
- };
-
- return result;
-}
-
-static inline
-Vec vec_entry_div(Vec v1, Vec v2)
-{
- Vec result = {
- .x = v1.x / v2.x,
- .y = v1.y / v2.y
- };
-
- return result;
-}
-
-static inline
-float rad_to_deg(float a)
-{
- return 180 / PI * a;
-}
-
-static inline
-Vec vec_norm(Vec v)
-{
- // TODO(#657): math/point/vec_norm: using vec_length is too expensive
- // It involves multiplication and sqrt. We can just check if its components are close to 0.0f.
-
- const float l = vec_length(v);
-
- if (l < 1e-6) {
- return vec(0.0f, 0.0f);
- }
-
- return vec(v.x / l, v.y / l);
-}
-
-static inline
-float vec_sqr_norm(Vec v)
-{
- return v.x * v.x + v.y * v.y;
-}
-
-#define vec_scale vec_scala_mult
-
-#endif // POINT_H_
#include <SDL.h>
#include <math.h>
-#include "math/point.h"
+#include "math/vec.h"
typedef enum Rect_side {
RECT_SIDE_LEFT = 0,
#ifndef TRIANGLE_H_
#define TRIANGLE_H_
-#include "math/point.h"
+#include "math/vec.h"
#include "math/rect.h"
typedef struct Triangle {
--- /dev/null
+#ifndef POINT_H_
+#define POINT_H_
+
+#include "math/pi.h"
+
+typedef struct Point {
+ float x, y;
+} Point;
+
+typedef Point Vec;
+
+static inline
+Vec vec(float x, float y)
+{
+ Vec result = {
+ .x = x,
+ .y = y
+ };
+ return result;
+}
+
+static inline
+Vec vec_scala_mult(Vec v, float scalar)
+{
+ Vec result = {
+ .x = v.x * scalar,
+ .y = v.y * scalar
+ };
+ return result;
+}
+
+static inline
+Vec vec_from_polar(float arg, float mag)
+{
+ return vec_scala_mult(
+ vec(cosf(arg), sinf(arg)),
+ mag);
+}
+
+static inline
+Vec vec_from_ps(Point p1, Point p2)
+{
+ Vec result = {
+ .x = p2.x - p1.x,
+ .y = p2.y - p1.y
+ };
+ return result;
+}
+
+static inline
+float vec_arg(Vec v)
+{
+ return atan2f(v.y, v.x);
+}
+
+static inline
+float vec_mag(Vec v)
+{
+ return sqrtf(v.x * v.x + v.y * v.y);
+}
+
+static inline
+Vec vec_sum(Vec v1, Vec v2)
+{
+ Vec result = {
+ .x = v1.x + v2.x,
+ .y = v1.y + v2.y
+ };
+ return result;
+}
+
+static inline
+Vec vec_sub(Vec v1, Vec v2)
+{
+ Vec result = {
+ .x = v1.x - v2.x,
+ .y = v1.y - v2.y
+ };
+ return result;
+}
+
+static inline
+Vec vec_neg(Vec v)
+{
+ Vec result = {
+ .x = -v.x,
+ .y = -v.y
+ };
+
+ return result;
+}
+
+static inline
+float vec_length(Vec v)
+{
+ return sqrtf(v.x * v.x + v.y * v.y);
+}
+
+static inline
+void vec_add(Vec *v1, Vec v2)
+{
+ v1->x += v2.x;
+ v1->y += v2.y;
+}
+
+static inline
+Vec vec_entry_mult(Vec v1, Vec v2)
+{
+ Vec result = {
+ .x = v1.x * v2.x,
+ .y = v1.y * v2.y
+ };
+
+ return result;
+}
+
+static inline
+Vec vec_entry_div(Vec v1, Vec v2)
+{
+ Vec result = {
+ .x = v1.x / v2.x,
+ .y = v1.y / v2.y
+ };
+
+ return result;
+}
+
+static inline
+float rad_to_deg(float a)
+{
+ return 180 / PI * a;
+}
+
+static inline
+Vec vec_norm(Vec v)
+{
+ // TODO(#657): math/point/vec_norm: using vec_length is too expensive
+ // It involves multiplication and sqrt. We can just check if its components are close to 0.0f.
+
+ const float l = vec_length(v);
+
+ if (l < 1e-6) {
+ return vec(0.0f, 0.0f);
+ }
+
+ return vec(v.x / l, v.y / l);
+}
+
+static inline
+float vec_sqr_norm(Vec v)
+{
+ return v.x * v.x + v.y * v.y;
+}
+
+#define vec_scale vec_scala_mult
+
+#endif // POINT_H_
#include <SDL.h>
#include "color.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "math/triangle.h"
// TODO(#474): there are no logging SDL wrappers (similar to system/nth_alloc)
#include "color.h"
#include "game/sprite_font.h"
#include "console_log.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "system/str.h"
#include "system/lt.h"
#include "system/nth_alloc.h"
#ifndef CONSOLE_LOG_H_
#define CONSOLE_LOG_H_
-#include "math/point.h"
+#include "math/vec.h"
#include "game/camera.h"
typedef struct Console_Log Console_Log;
#include <SDL.h>
#include "color.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "game/camera.h"
typedef struct Edit_field Edit_field;
#include "system/lt.h"
#include "system/nth_alloc.h"
#include "system/str.h"
-#include "math/point.h"
+#include "math/vec.h"
#include "game/sprite_font.h"
#include "system/log.h"
#include <SDL.h>
-#include "math/point.h"
+#include "math/vec.h"
#include "./wiggly_text.h"
#include "system/lt.h"