aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-02-19 22:35:48 +0100
committerJulian T <julian@jtle.dk>2020-02-19 22:35:48 +0100
commit63a84080f9f0e3d719d5470e370584a5eff18a47 (patch)
tree58264ab5ee632218ab898f70a8a0170b29e595bf /main.c
Viewpoint system and share/ray intersection working
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..0f64c57
--- /dev/null
+++ b/main.c
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+
+#include "vector.h"
+#include "viewpoint.h"
+#include "ray.h"
+
+typedef struct {
+ viewpoint_t view;
+} space_t;
+
+int main()
+{
+ printf("Starting\n");
+
+ space_t s;
+
+ vector_set(&s.view.position, 10, 20, 10);
+ vector_set(&s.view.target, 0, 0, 0);
+ s.view.width = 100;
+ s.view.height = 100;
+
+ viewpoint_init(&s.view);
+
+ ray_t r;
+ r.start = &s.view.position;
+ viewpoint_ray(&s.view, &r.direction, 66, 33);
+
+ vector_print(&r.direction);
+
+ plane_t pl;
+ pl.start = vector_set(NULL, 0, 0, 12);
+ vector_set(&pl.norm, 6, 2, 0);
+ vector_scale_inv(&pl.norm, &pl.norm, vector_len(&pl.norm));
+ vector_print(&pl.norm);
+
+ printf("Intersect distance %f\n", ray_intersect_plane(&pl, &r));
+
+
+}