DiaCanvas2 Reference Manual: Version 0.9.0 | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
This is not really a class, but rather a bunch of function used to manipulate and do calculations with points and rectangles.
gdouble dia_distance_point_point (DiaPoint *p1, DiaPoint *p2); |
Distance from one point to another point.
p1 : |
|
p2 : |
|
Returns : | Distance. |
gdouble dia_distance_point_point_manhattan (DiaPoint *p1, DiaPoint *p2); |
Fast distance calculation (but less accurate).
p1 : |
|
p2 : |
|
Returns : | Distance. |
gdouble dia_distance_line_point (DiaPoint *line_start, DiaPoint *line_end, DiaPoint *point, gdouble line_width, DiaCapStyle style, DiaPoint *point_on_line); |
This function estimates the distance from a point to a line segment specified by two endpoints. If the point is on the line, 0.0 is returned. Otherwise the distance in the R^2 metric from the point to the nearest point on the line segment is returned. Does one sqrt per call.
If point can not be projected on the line, the distance from the start or end point is taken. If style is DIA_CAP_ROUND or DIA_CAP_SQUARE the distance is decreased by line_width/2.
line_start : |
|
line_end : |
|
point : |
|
line_width : |
|
style : |
|
point_on_line : | OUT point on the line, closest to point. May be NULL. |
Returns : | Distance from the point to the line (this is equal to the distance from point to point_on_line - line_width/2). |
gdouble dia_distance_rectangle_point (DiaRectangle *rect, DiaPoint *point); |
This function estimates the distance from a point to a rectangle. If the point is in the rectangle, 0.0 is returned. Otherwise the distance in a manhattan metric from the point to the nearest point on the rectangle is returned.
rect : |
|
point : |
|
Returns : | Distance from the rectangle to the point, 0.0 if the point is inside the rectangle. |
gboolean dia_intersection_line_line (DiaPoint *start1, DiaPoint *end1, DiaPoint *start2, DiaPoint *end2, DiaPoint *intersect); |
Find the intersection point of two lines, if any.
start1 : | Starting point of line 1. |
end1 : | End of line 1. |
start2 : | Start of line 2. |
end2 : | End of line 2. |
intersect : | If TRUE is returned, intersect contains the point of intersection. |
Returns : | TRUE if an intersection point is found, FALSE otherwise. |
gint dia_intersection_line_rectangle (DiaPoint *start, DiaPoint *end, DiaRectangle *rect, DiaPoint intersect[2]); |
Find the intersection points of a line and a rectangle by comparing each border line of the rectangle with the line's intersection.
start : |
|
end : |
|
rect : |
|
intersect : | A list of intersections. |
Returns : | Number of intersections: 0, 1 or 2. |
gboolean dia_intersection_rectangle_rectangle (DiaRectangle *r1, DiaRectangle *r2); |
Determine if two rectangles intersect with each other.
r1 : |
|
r2 : |
|
Returns : | TRUE if an intersection is found, FALSE otherwise. |
void dia_rectangle_add_point (DiaRectangle *rect, DiaPoint *p); |
Extent rect so point p is also in the rectangle.
rect : |
|
p : |
|