C-Playground/lib/raytracer.h

50 lines
1.3 KiB
C

#ifndef RAYTRACER_H
#define RAYTRACER_H
#include <stdint.h>
typedef struct origin_3d {
double x;
double y;
double z;
} origin_3d;
typedef struct vector_3d {
origin_3d origin;
origin_3d direction;
double magnitude;
} vector_3d;
typedef struct raytracer_pixel_color {
uint8_t blue;
uint8_t green;
uint8_t red;
} raytracer_pixel_color;
typedef struct sphere_object {
origin_3d origin;
double radius;
} sphere_object;
/* TODO: Probably better to have this allocated dynamically/make more advanced resizeable array datatype. Need to write decent memory allocator first. Also add more object types */
typedef struct object_array {
unsigned int length;
sphere_object data[];
} object_array;
typedef struct camera {
origin_3d origin;
double distance_to_canvas;
double width_canvas_pixel_spacing;
double height_canvas_pixel_spacing;
double total_canvas_width;
double total_canvas_height;
} camera;
origin_3d multiply_origin_3d_by_scalar(origin_3d origin_3d_in, double scalar);
origin_3d add_origin_3d_together(origin_3d origin_3d_in_x, origin_3d *origin_3d_in_y);
origin_3d get_point_along_vector_3d(vector_3d *vector_3d_in, double magnitude);
camera init_camera(origin_3d origin, double distance_to_canvas, double width_canvas_pixel_spacing, double height_canvas_pixel_spacing);
#endif