Geometry
SHARED FUNCTIONS
distance_2d
Calculates the distance between two 2D points.
Parameters
p1:
tablep2:
table
Returns
number
bdtk.distance_2d(p1, p2)distance_3d
Calculates the distance between two 3D points.
Parameters
p1:
tablep2:
table
Returns
number
bdtk.distance_3d(p1, p2)midpoint
Returns the midpoint between two 3D points.
Parameters
p1:
tablep2:
table
Returns
table
bdtk.midpoint(p1, p2)is_point_in_rect
Determines if a point is inside a given 2D rectangle boundary.
Parameters
point:
tablerect:
table
Returns
boolean
bdtk.is_point_in_rect(point, rect)is_point_in_box
Determines if a point is inside a given 3D box boundary.
Parameters
point:
tablebox:
table
Returns
boolean
bdtk.is_point_in_box(point, box)is_point_on_line_segment
Determines if a point is on a line segment defined by two 2D points.
Parameters
point:
tableline_start:
tableline_end:
table
Returns
boolean
bdtk.is_point_on_line_segment(point, line_start, line_end)project_point_on_line
Projects a point onto a line segment defined by two 2D points.
Parameters
p:
tablep1:
tablep2:
table
Returns
table
bdtk.project_point_on_line(p, p1, p2)calculate_slope
Calculates the slope of a line given two 2D points.
Parameters
p1:
tablep2:
table
Returns
number
bdtk.calculate_slope(p1, p2)angle_between_points
Returns the angle between two 2D points in degrees.
Parameters
p1:
tablep2:
table
Returns
number
bdtk.angle_between_points(p1, p2)angle_between_3_points
Calculates the angle between three 3D points (p1, p2 as center, p3).
Parameters
p1:
tablep2:
tablep3:
table
Returns
number
bdtk.angle_between_3_points(p1, p2, p3)do_circles_intersect
Determines if two circles defined by center and radius intersect.
Parameters
c1_center:
tablec1_radius:
numberc2_center:
tablec2_radius:
number
Returns
boolean
bdtk.do_circles_intersect(c1_center, c1_radius, c2_center, c2_radius)is_point_in_circle
Determines if a point is inside a circle defined by center and radius.
Parameters
point:
tablecircle_center:
tablecircle_radius:
number
Returns
boolean
bdtk.is_point_in_circle(point, circle_center, circle_radius)do_lines_intersect
Determines if two 2D line segments intersect.
Parameters
l1_start:
tablel1_end:
tablel2_start:
tablel2_end:
table
Returns
boolean
bdtkbdtk.do_lines_intersect(l1_start, l1_end, l2_start, l2_end)line_intersects_circle
Determines if a line segment intersects a circle.
Parameters
line_start:
tableline_end:
tablecircle_center:
tablecircle_radius:
number
Returns
boolean
bdtk.line_intersects_circle(line_start, line_end, circle_center, circle_radius)does_rect_intersect_line
Determines if a rectangle intersects with a 2D line segment.
Parameters
rect:
tableline_start:
tableline_end:
table
Returns
boolean
bdtk.does_rect_intersect_line(rect, line_start, line_end)closest_point_on_line_segment
Determines the closest point on a 2D line segment to a given point.
Parameters
point:
tableline_start:
tableline_end:
table
Returns
table
bdtk.closest_point_on_line_segment(point, line_start, line_end)triangle_area_3d
Calculates the area of a 3D triangle given three points.
Parameters
p1:
tablep2:
tablep3:
table
Returns
number
bdtk.triangle_area_3d(p1, p2, p3)is_point_in_sphere
Determines if a point is inside a 3D sphere defined by center and radius.
Parameters
point:
tablesphere_center:
tablesphere_radius:
number
Returns
boolean
bdtk.is_point_in_sphere(point, sphere_center, sphere_radius)do_spheres_intersect
Determines if two spheres intersect.
Parameters
s1_center:
tables1_radius:
numbers2_center:
tables2_radius:
number
Returns
boolean
bdtk.do_spheres_intersect(s1_center, s1_radius, s2_center, s2_radius)is_point_in_convex_polygon
Determines if a point is inside a 2D convex polygon.
Parameters
point:
tablepolygon:
table
Returns
boolean
bdtk.is_point_in_convex_polygon(point, polygon)rotate_point_around_point_2d
Rotates a point around another point in 2D by a given angle in degrees.
Parameters
point:
tablepivot:
tableangle_degrees:
number
Returns
table
bdtk.rotate_point_around_point_2d(point, pivot, angle_degrees)distance_point_to_plane
Calculates the distance from a point to a plane.
Parameters
point:
tableplane_point:
tableplane_normal:
table
Returns
number
bdtk.distance_point_to_plane(point, plane_point, plane_normal)rotation_to_direction
Converts a rotation vector to a direction vector.
Parameters
rotation:
table
Returns
table
bdtk.rotation_to_direction(rotation)rotate_box
Rotates a box around a central point in 3D by a given heading.
Parameters
center:
tablewidth:
numberlength:
numberheading:
number
Returns
table
bdtk.rotate_box(center, width, length, heading)calculate_rotation_matrix
Calculates a rotation matrix from heading, pitch, and roll.
Parameters
heading:
numberpitch:
numberroll:
number
Returns
table
geometry.calculate_rotation_matrix(heading, pitch, roll)translate_point_to_local_space
Translates a point to a box's local coordinate system using a rotation matrix.
Parameters
point:
tablebox_origin:
tablerot_matrix:
table
Returns
table
bdtk.translate_point_to_local_space(point, box_origin, rot_matrix)is_point_in_oriented_box
Determines if a point is inside an oriented 3D box.
Parameters
point:
tablebox:
table
Returns
boolean
bdtk.is_point_in_oriented_box(point, box)Last updated