bitlib_c
0.2.4
|
#include <stdbool.h>
Go to the source code of this file.
Classes | |
struct | Point |
struct | Point_List |
Typedefs | |
typedef struct Point | bl_point |
typedef struct Point_List | bl_point_list |
typedef struct Point_List bl_point_list |
A struct holding the head and tail of a linked list.
void bl_add_point | ( | bl_point_list * | list, |
bl_point * | p | ||
) |
Adds a point to a point list.
bl_point_list | *list The list to add to. |
bl_point | *point The point to add. |
Examples
bl_point *p = bl_make_point(100, 100); bl_add_point(path, p);
void bl_add_point_xy | ( | bl_point_list * | list, |
double | x, | ||
double | y | ||
) |
Adds an x, y point to a point list.
bl_point_list | *list The list to add to. |
double | x The x value of the point to add. |
double | y The y value of the point to add. |
Examples
bl_add_point_xy(path, 100, 100);
Returns the angle between two lines defined by four points.
bl_point | *p0 The first point of the first line. |
bl_point | *p1 The second point of the first line. |
bl_point | *p2 The first point of the second line. |
bl_point | *p4 The second point of the second line. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *p1 = bl_make_point(200, 150); bl_point *p2 = bl_make_point(100, 100); bl_point *p3 = bl_make_point(140, 300); double angle = bl_angle_between(p0, p1, p2, p3);
Returns a point on a Bezier curve.
The t
parameter is in the range of 0 to 1. 0 will return the first point. 1 will return the final point. A value between 0 and 1 will return a point along the Bezier path formed by the four points.
bl_point | *p0 The first point. |
bl_point | *p1 The second point. |
bl_point | *p2 The third point. |
bl_point | *p3 The fourth point. |
double | t The interpolation value. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *p1 = bl_make_point(200, 150); bl_point *p2 = bl_make_point(300, 100); bl_point *p3 = bl_make_point(400, 300); bl_point *p4 = bl_bezier_point(p0, p1, p2, p3, 0.2);
Returns the dot product of two angles formed by four points.
bl_point | *p0 The first point of the first line. |
bl_point | *p1 The second point of the first line. |
bl_point | *p2 The first point of the second line. |
bl_point | *p4 The second point of the second line. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *p1 = bl_make_point(200, 150); bl_point *p2 = bl_make_point(100, 100); bl_point *p3 = bl_make_point(140, 300); double dp = bl_dot_product(p0, p1, p2, p3);
Returns a new point interpolated between two other points.
double | t The interpolation value. Usually 0 to 1. |
bl_point | *p0 The first point. |
bl_point | *p1 The second point. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *p1 = bl_make_point(200, 500); bl_point *p2 = bl_lerp_point(0.35, p0, p1);
bl_point* bl_make_point | ( | double | x, |
double | y | ||
) |
Creates a new point.
double | x The x value of the point. |
double | y The y value of the point. |
Examples
bl_point *p = bl_make_point(100, 100);
bl_point_list* bl_make_point_list | ( | ) |
Creates a linked list of point objects.
Examples
bl_point_list *path = bl_make_point_list();
double bl_point_angle | ( | bl_point * | p | ) |
Returns the angle from the origin to a point.
bl_point | *p The point. |
Examples
bl_point *p = bl_make_point(200, 150); double angle = bl_point_angle(p);
Returns the distance between two points.
bl_point | *p0 The first point. |
bl_point | *p1 The second point. |
Examples
bl_point *p0 = bl_make_point(200, 150); bl_point *p1 = bl_make_point(140, 300); double dist = bl_point_distance(p0, p1);
bl_point* bl_point_from_polar | ( | double | angle, |
double | radius | ||
) |
Returns a new point based on an angle and radius.
double | angle The angle from the origin. |
double | radius The distance from the origin. |
Examples
bl_point *p = bl_point_from_polar(PI / 4, 100);
int bl_point_list_count | ( | bl_point_list * | list | ) |
Returns the number of points in a point list.
bl_point_list | *list The list to get a count for. |
Examples
int count = bl_point_list_count(path);
void bl_point_list_destroy | ( | bl_point_list * | list | ) |
Frees the memory for each point in a point list and for the list itself.
bl_point_list | *list The list to destroy. |
Examples
bl_point_list_destroy(path);
double bl_point_magnitude | ( | bl_point * | p | ) |
Returns the magnitude (distance from origin) of a point.
bl_point | *p The point. |
Examples
bl_point *p = bl_make_point(200, 150); double mag = bl_point_magnitude(p);
void bl_point_rotate | ( | bl_point * | p, |
double | angle | ||
) |
Rotates a point around the origin.
bl_point | *p The point. |
double | angle The angle to rotate by. |
Examples
bl_point *p = bl_make_point(200, 150); bl_point_rotate(p, PI / 4);
void bl_point_scale | ( | bl_point * | p, |
double | sx, | ||
double | sy | ||
) |
Scales a point from the origin.
bl_point | *p The point. |
double | sx How much to scale on the x-axis. |
double | sy How much to scale on the y-axis. |
Examples
bl_point *p = bl_make_point(200, 150); bl_point_scale(p, 2, 3);
void bl_point_translate | ( | bl_point * | p, |
double | x, | ||
double | y | ||
) |
Translates a point.
bl_point | *p The point. |
double | x How much to translate on the x-axis. |
double | y How much to translate on the y-axis. |
Examples
bl_point *p = bl_make_point(200, 150); bl_point_translate(p, 100, 50);
Returns a point on a quadratic Bezier curve.
The t
parameter is in the range of 0 to 1. 0 will return the first point. 1 will return the final point. A value between 0 and 1 will return a point along the quadratic Bezier path formed by the three points.
bl_point | *p0 The first point. |
bl_point | *p1 The second point. |
bl_point | *p2 The third point. |
double | t The interpolation value. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *p1 = bl_make_point(200, 150); bl_point *p2 = bl_make_point(300, 100); bl_point *p4 = bl_quadratic_point(p0, p1, p2, p3, 0.2);
bl_point* bl_random_point | ( | double | x, |
double | y, | ||
double | w, | ||
double | h | ||
) |
Returns a random point withint a defined rectangle.
double | x The x position of the rectangle. |
double | y The y position of the rectangle. |
double | w The width of the rectangle. |
double | h The height of the rectangle. |
Examples
bl_point *p = bl_random_point(0, 0, 500, 500);
bl_point* bl_random_point_in_circle | ( | double | x, |
double | y, | ||
double | r | ||
) |
Returns a random point within a defined circle.
double | x The x position of the circle. |
double | y The y position of the circle. |
double | r The radius of the circle. |
Examples
bl_point *p = bl_random_point_in_circle(100, 100, 50);
Returns a random point that will be within a triangle defined by three points.
bl_point | *p0 The first point of the triangle. |
bl_point | *p1 The second point of the triangle. |
bl_point | *p2 The third point of the triangle. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *p1 = bl_make_point(200, 150); bl_point *p2 = bl_make_point(140, 300); bl_point *p3 = bl_random_point_in_triangle(p0, p1, p2);
Returns whether or not too line segments intersect.
bl_point | *p0 The first point of the first line. |
bl_point | *p1 The second point of the first line. |
bl_point | *p2 The first point of the second line. |
bl_point | *p4 The second point of the second line. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *p1 = bl_make_point(200, 150); bl_point *p2 = bl_make_point(300, 100); bl_point *p3 = bl_make_point(400, 300); bool intersect = bl_segment_intersect(p0, p1, p2, p3);
bl_point* bl_tangent_point_to_circle | ( | bl_point * | p, |
double | x, | ||
double | y, | ||
double | r, | ||
bool | anticlockwise | ||
) |
Given the specified point and circle, finds another point on the circle that will form a line tangent to the circle.
bl_point | *p The initial point. |
double | x The x position of the circle. |
double | y The y position of the circle. |
double | r The radius of the circle. |
bool | anticlockwise Which side of the circle to find the tangent point on. |
Examples
bl_point *p0 = bl_make_point(100, 100); bl_point *tangent = bl_tangent_point_to_circle(p, 200, 100, 50, false);