Geometry
SHARED FUNCTIONS
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
bdtk.distance_3d(p1, p2)
midpoint
Returns the midpoint between two 3D points.
Parameters
p1:
table
p2:
table
Returns
table
bdtk.midpoint(p1, p2)
is_point_in_rect
Determines if a point is inside a given 2D rectangle boundary.
Parameters
point:
table
rect:
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:
table
box:
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:
table
line_start:
table
line_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:
table
p1:
table
p2:
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:
table
p2:
table
Returns
number
bdtk.calculate_slope(p1, p2)
angle_between_points
Returns the angle between two 2D points in degrees.
Parameters
p1:
table
p2:
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:
table
p2:
table
p3:
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:
table
c1_radius:
number
c2_center:
table
c2_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:
table
circle_center:
table
circle_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:
table
l1_end:
table
l2_start:
table
l2_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:
table
line_end:
table
circle_center:
table
circle_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:
table
line_start:
table
line_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:
table
line_start:
table
line_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:
table
p2:
table
p3:
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:
table
sphere_center:
table
sphere_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:
table
s1_radius:
number
s2_center:
table
s2_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:
table
polygon:
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:
table
pivot:
table
angle_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:
table
plane_point:
table
plane_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:
table
width:
number
length:
number
heading:
number
Returns
table
bdtk.rotate_box(center, width, length, heading)
calculate_rotation_matrix
Calculates a rotation matrix from heading, pitch, and roll.
Parameters
heading:
number
pitch:
number
roll:
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:
table
box_origin:
table
rot_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:
table
box:
table
Returns
boolean
bdtk.is_point_in_oriented_box(point, box)
Last updated