support module for some geometric mesurements ( geometric tramforms are in transform.py)
Imported modules
|
|
from __future__ import division
from math import sqrt, atan2, pi, cos, sin
from misc import signum, normalize_coords
import operator
|
Functions
|
|
angle_between_lines
clockwise_angle_from_east
find_parallel
get_parallel_distance
get_parallel_signum
intersection_of_line_and_rect
on_which_side_is_point
point_distance
point_on_circle
|
|
angle_between_lines
|
angle_between_lines ( l1, l2 )
returns angle between two lines
|
|
clockwise_angle_from_east
|
clockwise_angle_from_east ( dx, dy )
returns the angle in clockwise direction between the center-east line and direction
|
|
find_parallel
|
find_parallel (
x1,
y1,
x2,
y2,
d,
)
returns tuple of coordinates for parallel abscissa in distance d
|
|
get_parallel_distance
|
get_parallel_distance ( l1, l2 )
returns distance of two parallels - does not check whether the two are really parallels
|
|
get_parallel_signum
|
get_parallel_signum ( l1, l2 )
|
|
intersection_of_line_and_rect
|
intersection_of_line_and_rect (
line,
rect,
round_edges=0,
)
finds a point where a line and a rectangle intersect,
both are given as lists of len == 4
|
|
on_which_side_is_point
|
on_which_side_is_point (
line,
point,
threshold=0,
)
tells whether a point is on one side of a line or on the other (1,0,-1) - 0 is for point on line.
line is given as sequence of four coordinates, point as sequence of two coords,
threshold means what smallest angle is considered to still be on the line
|
|
point_distance
|
point_distance (
x1,
y1,
x2,
y2,
)
|
|
point_on_circle
|
point_on_circle (
center_x,
center_y,
radius,
direction=(),
resolution=15,
)
finds point on circle in direction of (dx, dy), optionaly rounds the angle
according to resolution
|
|