bitlib_c
0.2.4
|
#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) |
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.
double | x0 The first point. |
double | x1 The second point. |
double | x2 The third point. |
double | x3 The fourth point. |
double | t The interpolation value. |
Examples
double x = bl_bezier(100, 200, 300, 400, 0.4); double y = bl_bezier(100, 0, 300, 100, 0.4);
bool bl_circle_intersect | ( | double | cx0, |
double | cy0, | ||
double | cr0, | ||
double | cx1, | ||
double | cy1, | ||
double | cr1 | ||
) |
Returns whether or not two circles are intersecting.
double | cx0 The x position of the first circle. |
double | cy0 The y position of the first circle. |
double | cr0 The radius of the first circle. |
double | cx1 The x position of the second circle. |
double | cy1 The y position of the second circle. |
double | cr1 The radius of the second circle. |
Examples
bool collision = bl_circle_intersect(100, 100, 50, 150, 150, 100);
double bl_distance_xy | ( | double | x0, |
double | y0, | ||
double | x1, | ||
double | y1 | ||
) |
Returns the distance between two x, y points.
double | x0 The x value of the first point. |
double | y0 The y value of the first point. |
double | x1 The x value of the second point. |
double | y1 The y value of the second point. |
Examples
double dist = bl_distance_xy(100, 100, 200, 200);
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.
double | x0 The first point. |
double | x1 The second point. |
double | x2 The third point. |
double | t The interpolation value. |
Examples
double x = bl_quadratic_bezier(100, 200, 300, 0.4); double y = bl_quadratic_bezier(100, 0, 300, 0.4);
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.
double | x The x value of the point. |
double | y The y value of the point. |
double | cx The x position of the circle. |
double | cy The y position of the circle. |
double | cr The radius of the circle. |
Examples
bool in_circle = bl_xy_in_circle(100, 100, 150, 150, 100);
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.
double | x The x value of the point. |
double | y The y value of the point. |
double | rx The x position of the rectangle. |
double | ry The y position of the rectangle. |
double | rw The width of the rectangle. |
double | rh The height of the rectangle. |
Examples
bool in_rect = bl_xy_in_rect(100, 100, 50, 50, 200, 300);
double bl_xy_magnitude | ( | double | x, |
double | y | ||
) |
Returns the magnitude (distance from origin) of an x, y point.
double | x The x value of the point. |
double | y The y value of the point. |
Examples
double mag = bl_xy_magnitude(100, 200);