Module geometry

Source
Expand description

Contains functions that are related to the geometry of shapes and their interaction. This includes things like intersection of shapes and length of vectors.

Structs§

Point
Position
Represents the size, location and centerpoint of a shape. We align shapes along their center points, and have edges directed at the center. Shapes like Box and Circle have their center point in the middle, but labels have their center point in one of the sides to make sure that edges don’t obscure the text. The halo is the gap around the shape where nothing can be placed and it is applied symmetrically to the sides.

Functions§

create_vector_of_length
do_boxes_intersect
\return True if the boxes (defined by the bounding box) intersect.
ellipse_line_intersection
\returns the intersection point for a line with slope \p m with an ellipse with the formula. 1 = (x^2 / a^2) + (y^2 / b^2). Replace Y with the line equation and isolate x and solve to get the intersection point with the ellipse. Notice that a line has two intersection points with a circle, so users need to figure out which of the two values (+X, +Y) or (-X, -Y) is relevant.
get_connection_point_for_box
This is the implementation of get_connector_location for box-like shapes. ‘See get_connector_location’ for details.
get_connection_point_for_circle
This is the implementation of get_connector_location for circle-like shapes. ‘See get_connector_location’ for details.
get_passthrough_path_invisible
get_size_for_str
Estimate the bounding box of some rendered text.
in_range
\return true if \p x is in the inclusive range P.x .. P.y.
interpolate
Perform linear interpolation of the vectors v0 and v1, using the ratio w which is assumed to be between 0..1.
make_size_square
Make the shape have the same X and Y values.
normalize_scale_vector
Return the normalized vector \p v multiplied by the scalar \p s.
pad_shape_scalar
Increase the size of X and Y by \p s.
segment_rect_intersection
\return True if the segment intersects the rect.
weighted_median
Return the weighted median for \p vec. This is the method that’s described in “DAG - A Program that Draws Directed Graphs” Gansner, North, Vo 1989. Pg 10.