Geometry

distance_2d

Calculates the distance between two 2D points.

Parameters

  • p1: table

  • p2: table

Returns

  • number

bdtk.distance_2d(p1, p2)

distance_3d

Calculates the distance between two 3D points.

Parameters

  • p1: table

  • p2: table

Returns

  • number


midpoint

Returns the midpoint between two 3D points.

Parameters

  • p1: table

  • p2: table

Returns

  • table


is_point_in_rect

Determines if a point is inside a given 2D rectangle boundary.

Parameters

  • point: table

  • rect: table

Returns

  • boolean


is_point_in_box

Determines if a point is inside a given 3D box boundary.

Parameters

  • point: table

  • box: table

Returns

  • boolean


is_point_on_line_segment

Determines if a point is on a line segment defined by two 2D points.

Parameters

  • point: table

  • line_start: table

  • line_end: table

Returns

  • boolean


project_point_on_line

Projects a point onto a line segment defined by two 2D points.

Parameters

  • p: table

  • p1: table

  • p2: table

Returns

  • table


calculate_slope

Calculates the slope of a line given two 2D points.

Parameters

  • p1: table

  • p2: table

Returns

  • number


angle_between_points

Returns the angle between two 2D points in degrees.

Parameters

  • p1: table

  • p2: table

Returns

  • number


angle_between_3_points

Calculates the angle between three 3D points (p1, p2 as center, p3).

Parameters

  • p1: table

  • p2: table

  • p3: table

Returns

  • number


do_circles_intersect

Determines if two circles defined by center and radius intersect.

Parameters

  • c1_center: table

  • c1_radius: number

  • c2_center: table

  • c2_radius: number

Returns

  • boolean


is_point_in_circle

Determines if a point is inside a circle defined by center and radius.

Parameters

  • point: table

  • circle_center: table

  • circle_radius: number

Returns

  • boolean


do_lines_intersect

Determines if two 2D line segments intersect.

Parameters

  • l1_start: table

  • l1_end: table

  • l2_start: table

  • l2_end: table

Returns

  • boolean


line_intersects_circle

Determines if a line segment intersects a circle.

Parameters

  • line_start: table

  • line_end: table

  • circle_center: table

  • circle_radius: number

Returns

  • boolean


does_rect_intersect_line

Determines if a rectangle intersects with a 2D line segment.

Parameters

  • rect: table

  • line_start: table

  • line_end: table

Returns

  • boolean


closest_point_on_line_segment

Determines the closest point on a 2D line segment to a given point.

Parameters

  • point: table

  • line_start: table

  • line_end: table

Returns

  • table


triangle_area_3d

Calculates the area of a 3D triangle given three points.

Parameters

  • p1: table

  • p2: table

  • p3: table

Returns

  • number


is_point_in_sphere

Determines if a point is inside a 3D sphere defined by center and radius.

Parameters

  • point: table

  • sphere_center: table

  • sphere_radius: number

Returns

  • boolean


do_spheres_intersect

Determines if two spheres intersect.

Parameters

  • s1_center: table

  • s1_radius: number

  • s2_center: table

  • s2_radius: number

Returns

  • boolean


is_point_in_convex_polygon

Determines if a point is inside a 2D convex polygon.

Parameters

  • point: table

  • polygon: table

Returns

  • boolean


rotate_point_around_point_2d

Rotates a point around another point in 2D by a given angle in degrees.

Parameters

  • point: table

  • pivot: table

  • angle_degrees: number

Returns

  • table


distance_point_to_plane

Calculates the distance from a point to a plane.

Parameters

  • point: table

  • plane_point: table

  • plane_normal: table

Returns

  • number


rotation_to_direction

Converts a rotation vector to a direction vector.

Parameters

  • rotation: table

Returns

  • table


rotate_box

Rotates a box around a central point in 3D by a given heading.

Parameters

  • center: table

  • width: number

  • length: number

  • heading: number

Returns

  • table


calculate_rotation_matrix

Calculates a rotation matrix from heading, pitch, and roll.

Parameters

  • heading: number

  • pitch: number

  • roll: number

Returns

  • table


translate_point_to_local_space

Translates a point to a box's local coordinate system using a rotation matrix.

Parameters

  • point: table

  • box_origin: table

  • rot_matrix: table

Returns

  • table


is_point_in_oriented_box

Determines if a point is inside an oriented 3D box.

Parameters

  • point: table

  • box: table

Returns

  • boolean

Last updated