geometry module¶
-
class
geometry.TGeometry¶ Bases:
objectClass contains static methods used for coordinates calculations (window and model system) and other geometry related procedures.
-
static
dist_model_to_window(win_dist, min_model, max_model, min_window, max_window)¶ Calculate distance in the windows coordinate system from a given distance in model coordinate system.
Parameters: - win_dist (TPoint) – distance in window coordinate system (pixels).
- min_model (TPoint) – visible model area lower left point in m.
- max_model (TPoint) – vivible model area upper right point in m.
- min_window (TPoint) – model box lower left point in pixels.
- max_window (TPoint) – model box upper right point in pixels.
Returns: distance in the windows coordinate system.
Return type: float
-
static
dist_window_to_model(mod_dist, min_model, max_model, min_window, max_window, dx, dy)¶ Calculate distance in the model coordinate system from a given distance in window coordinate system.
Parameters: - mod_dist (TPoint) – distance in model coordinate system (m).
- min_model (TPoint) – visible model area lower left point in m.
- max_model (TPoint) – vivible model area upper right point in m.
- min_window (TPoint) – model box lower left point in pixels.
- max_window (TPoint) – model box upper right point in pixels.
- dx (float) – model discretisation step in x direction.
- dy (float) – model discretisation step in y direction.
Returns: distance in the model coordinate system.
Return type: float
-
static
intersect(point1, point2, point3, point4)¶ Detect if two line segments intersect.
Parameters: Returns: True if the line segments intersect, False otherwise.
Return type: boolean
-
static
model_to_window(mod_pt, min_model, max_model, min_window, max_window)¶ Calculate window coordinates from given model coordinates.
Parameters: - mod_pt (TPoint) – point in model coordinate system (m).
- min_model (TPoint) – visible model area lower left point in m.
- max_model (TPoint) – vivible model area upper right point in m.
- min_window (TPoint) – model box lower left point in pixels.
- max_window (TPoint) – model box upper right point in pixels.
Returns: window coordinates.
Return type:
-
static
point_visible(point, min_model, max_model)¶ Detect if a given point is within visible area of model.
Parameters: Returns: True if the given point lies within the models visible area, False otherwise.
Return type: boolean
-
static
polygon_area(points)¶ Calculate the area of polygon enclosed by points in given list.
Parameters: points (list of TPoint) – list of consecutive polygons points. Returns: area of a polygon. Return type: float
-
static
position_in_boundries(pos, box_min, box_max)¶ Detect if a given mouse position lies within model.
Parameters: Returns: True if the given position lies within the model boundaries, False otherwise.
Return type: boolean
-
static
round_to_multiple(x, m)¶ Round given float to nearest multiple of another real.
Parameters: - x (float) – number to be rounded.
- m (float) – number to multiple of which x is to be rounded to.
Returns: rounded number.
Return type: float
-
static
window_to_model(window_pt, min_model, max_model, min_window, max_window, dx, dy)¶ Calculate model coordinates from given windows coordinates.
Parameters: - window_pt (TPoint) – point in window coordinates system (pixels).
- min_model (TPoint) – visible model area lower left point in m.
- max_model (TPoin) – vivible model area upper right point in m.
- min_window (TPoint) – model box lower left point in pixels.
- max_window (TPoint) – model box upper right point in pixels.
- dx (float) – grid discretisation step in x direction.
- dy (float) – grid discretisation step in y direction.
Returns: model coordinates.
Return type:
-
static