SpaceCadetPinball/SpaceCadetPinball/maths.h

60 lines
1.3 KiB
C
Raw Normal View History

2020-11-08 16:37:59 +01:00
#pragma once
2020-11-21 16:14:40 +01:00
struct vector_type
{
float X;
float Y;
float Z;
2020-11-21 16:14:40 +01:00
};
2020-11-08 16:37:59 +01:00
2020-11-15 15:39:00 +01:00
struct __declspec(align(4)) rectangle_type
2020-11-08 16:37:59 +01:00
{
int XPosition;
int YPosition;
int Width;
int Height;
};
2020-11-21 16:14:40 +01:00
struct circle_type
{
vector_type Center;
2020-11-21 16:14:40 +01:00
float RadiusSq;
};
struct __declspec(align(4)) ray_type
{
vector_type Origin;
vector_type Direction;
float MaxDistance;
float MinDistance;
2020-11-21 16:14:40 +01:00
};
struct __declspec(align(4)) line_type
{
vector_type PerpendicularL;
vector_type Direction;
float PreComp1;
float OriginX;
float OriginY;
float CompTmp1;
2020-11-21 16:14:40 +01:00
float Unknown10;
float Unknown11;
};
2020-11-08 16:37:59 +01:00
class maths
{
public:
2020-11-15 15:39:00 +01:00
static void enclosing_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
static int rectangle_clip(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
static int overlapping_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
2020-11-21 16:14:40 +01:00
static float ray_intersect_circle(ray_type* ray, circle_type* circle);
static float normalize_2d(vector_type* vec);
static void line_init(line_type* line, float x0, float y0, float x1, float y1);
static float ray_intersect_line(ray_type* ray, line_type* line);
static void cross(vector_type* vec1, vector_type* vec2, vector_type* dstVec);
static float magnitude(vector_type* vec);
static void vector_add(vector_type* vec1Dst, vector_type* vec2);
2020-11-08 16:37:59 +01:00
};