Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Geometry2D

Inherits: Object

Provides methods for some common 2D geometric operations.

Description

Provides a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations in 2D.

Methods

PackedVector2Array[]

clip_polygons ( PackedVector2Array polygon_a, PackedVector2Array polygon_b )

PackedVector2Array[]

clip_polyline_with_polygon ( PackedVector2Array polyline, PackedVector2Array polygon )

PackedVector2Array

convex_hull ( PackedVector2Array points )

PackedVector2Array[]

decompose_polygon_in_convex ( PackedVector2Array polygon )

PackedVector2Array[]

exclude_polygons ( PackedVector2Array polygon_a, PackedVector2Array polygon_b )

Vector2

get_closest_point_to_segment ( Vector2 point, Vector2 s1, Vector2 s2 )

Vector2

get_closest_point_to_segment_uncapped ( Vector2 point, Vector2 s1, Vector2 s2 )

PackedVector2Array

get_closest_points_between_segments ( Vector2 p1, Vector2 q1, Vector2 p2, Vector2 q2 )

PackedVector2Array[]

intersect_polygons ( PackedVector2Array polygon_a, PackedVector2Array polygon_b )

PackedVector2Array[]

intersect_polyline_with_polygon ( PackedVector2Array polyline, PackedVector2Array polygon )

bool

is_point_in_circle ( Vector2 point, Vector2 circle_position, float circle_radius )

bool

is_point_in_polygon ( Vector2 point, PackedVector2Array polygon )

bool

is_polygon_clockwise ( PackedVector2Array polygon )

Variant

line_intersects_line ( Vector2 from_a, Vector2 dir_a, Vector2 from_b, Vector2 dir_b )

Dictionary

make_atlas ( PackedVector2Array sizes )

PackedVector2Array[]

merge_polygons ( PackedVector2Array polygon_a, PackedVector2Array polygon_b )

PackedVector2Array[]

offset_polygon ( PackedVector2Array polygon, float delta, PolyJoinType join_type=0 )

PackedVector2Array[]

offset_polyline ( PackedVector2Array polyline, float delta, PolyJoinType join_type=0, PolyEndType end_type=3 )

bool

point_is_inside_triangle ( Vector2 point, Vector2 a, Vector2 b, Vector2 c ) const

float

segment_intersects_circle (