bitlib_c  0.2.4
Functions
geom.h File Reference
#include <math.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

double bl_distance_xy (double x0, double y0, double x1, double y1)
 
bool bl_xy_in_rect (double x, double y, double rx, double ry, double rw, double rh)
 
bool bl_xy_in_circle (double x, double y, double cx, double cy, double cr)
 
double bl_xy_magnitude (double x, double y)
 
bool bl_circle_intersect (double cx0, double cy0, double cr0, double cx1, double cy1, double cr1)
 
double bl_bezier (double x0, double x1, double x2, double x3, double t)
 
double bl_quadratic_bezier (double x0, double x1, double x2, double t)
 

Function Documentation

◆ bl_bezier()

double bl_bezier ( double  x0,
double  x1,
double  x2,
double  x3,
double  t 
)

Returns a one-dimensional Bezier interpolation of four other values.

Normally this would be applied to both the x and y values of a 2d point.

Parameters
doublex0 The first point.
doublex1 The second point.
doublex2 The third point.
doublex3 The fourth point.
doublet The interpolation value.

Examples

double x = bl_bezier(100, 200, 300, 400, 0.4);
double y = bl_bezier(100, 0, 300, 100, 0.4);

◆ bl_circle_intersect()

bool bl_circle_intersect ( double  cx0,
double  cy0,
double  cr0,
double  cx1,
double  cy1,
double  cr1 
)

Returns whether or not two circles are intersecting.

Parameters
doublecx0 The x position of the first circle.
doublecy0 The y position of the first circle.
doublecr0 The radius of the first circle.
doublecx1 The x position of the second circle.
doublecy1 The y position of the second circle.
doublecr1 The radius of the second circle.
Returns
double

Examples

bool collision = bl_circle_intersect(100, 100, 50, 150, 150, 100);

◆ bl_distance_xy()

double bl_distance_xy ( double  x0,
double  y0,
double  x1,
double  y1 
)

Returns the distance between two x, y points.

Parameters
doublex0 The x value of the first point.
doubley0 The y value of the first point.
doublex1 The x value of the second point.
doubley1 The y value of the second point.
Returns
double

Examples

double dist = bl_distance_xy(100, 100, 200, 200);

◆ bl_quadratic_bezier()

double bl_quadratic_bezier ( double  x0,
double  x1,
double  x2,
double  t 
)

Returns a one-dimensional quadratic Bezier interpolation of three other values.

Normally this would be applied to both the x and y values of a 2d point.

Parameters
doublex0 The first point.
doublex1 The second point.
doublex2 The third point.
doublet The interpolation value.

Examples

double x = bl_quadratic_bezier(100, 200, 300, 0.4);
double y = bl_quadratic_bezier(100, 0, 300, 0.4);

◆ bl_xy_in_circle()

bool bl_xy_in_circle ( double  x,
double  y,
double  cx,
double  cy,
double  cr 
)

Returns whether or not an x, y point is within a circle.

Parameters
doublex The x value of the point.
doubley The y value of the point.
doublecx The x position of the circle.
doublecy The y position of the circle.
doublecr The radius of the circle.
Returns
bool

Examples

bool in_circle = bl_xy_in_circle(100, 100, 150, 150, 100);

◆ bl_xy_in_rect()

bool bl_xy_in_rect ( double  x,
double  y,
double  rx,
double  ry,
double  rw,
double  rh 
)

Returns whether or not an x, y point is within a rectangle.

Parameters
doublex The x value of the point.
doubley The y value of the point.
doublerx The x position of the rectangle.
doublery The y position of the rectangle.
doublerw The width of the rectangle.
doublerh The height of the rectangle.
Returns
double

Examples

bool in_rect = bl_xy_in_rect(100, 100, 50, 50, 200, 300);

◆ bl_xy_magnitude()

double bl_xy_magnitude ( double  x,
double  y 
)

Returns the magnitude (distance from origin) of an x, y point.

Parameters
doublex The x value of the point.
doubley The y value of the point.
Returns
double

Examples

double mag = bl_xy_magnitude(100, 200);