fastwater.otm_gpl.geometry module¶
@note … this work is based on a collaborative effort of the Telemac-Mascaret consortium
- @history 11/11/2011 – Sebastien E. Bourban
An accuracy has been introduced because Python does not seem to be accurate with sums and multiplications
- @history 07/12/2011 – Sebastien E. Bourban
Addition of 3 new geometrical tools: + get_segment_line_intersection (different from
get_segment_intersection)
get_plane_equation (of the form Z = a*X + b*Y + c)
get_triangle_area
- @history 07/01/2012 – Sebastien E. Bourban
Addition of a few geometrical tools, working on angles: + get_cone_angle ( based on arctan2 ) + get_cone_sin_angle ( S = ac.sin(B)/2 = det / 2 )
- @history 14/02/2012 – Sebastien E. Bourban, Laure C. Grignon
Addition of the is_inside_poly method to define whether a point is inside of a polygon based on the ray casting method
- @brief
Tools for trivial geometrical operations
- fastwater.otm_gpl.geometry.get_barycentric_weights(point_0, point_1, point_2, point_3)[source]¶
Returns the barycentric weights of point point_0 in regard to the three points (point_1, point_2, point_3)
@param point_0 (2-uple) Coordinates of the point for which we want the weight @param point_1 (2-uple) Coodiantes of the first of the three points @param point_2 (2-uple) Coodiantes of the second of the three points @param point_3 (2-uple) Coodiantes of the third of the three points
@returns (3-uple) weight in regard of each point
- fastwater.otm_gpl.geometry.get_distance_point_to_line(point_0, point_1, point_2)[source]¶
Returns the distance between a point and a line
@param point_0 (2-uple) Coodinates of the point @param point_1 (2-uple) Coodinates of the first point of the line @param point_2 (2-uple) Coodinates of the second point of the line
@returns (float) the distance
- fastwater.otm_gpl.geometry.get_norm2(point1, point2)[source]¶
Compute norm2 of points given in argument: sqrt((y_2-y_1)^2+(x_2-x_1)^2)
@param point1 (2-uple) Coordinates of the point (x1, y1) @param point2 (2-uple) Coordinates of the point (x2, y2)
@returns (float) The norm
- fastwater.otm_gpl.geometry.get_plane_equation(point_1, point_2, point_3)[source]¶
Find the equation of the plane defined by 3 points. The form of the equation is: Z = a*X + b*Y + c
@param point_1 (2-uple) coordiantes of the first point @param point_2 (2-uple) coordiantes of the second point @param point_3 (2-uple) coordiantes of the third point
@returns (3-uple) (a, b, c)
- fastwater.otm_gpl.geometry.get_segment_intersection(point_1, point_2, point_3, point_4)[source]¶
Returns the coordinate of the point at the intersection of two segments, defined by (point_1,point_2) and (point_3,point_4) and ratio (exaplined below)
@param point_1 (2-uple) first point of the first segment @param point_2 (2-uple) second point of the first segment @param point_3 (2-uple) first point of the second segment @param point_4 (2-uple) second point of the second segment
@return [[x0,y0], ratio] where x0 and y0 are the coordinates of the intersect point and ratio that is norm2(point0, point1)/norm2(point1, point2)
- fastwater.otm_gpl.geometry.get_segment_line_intersection(t_1, t_2, t_3, t_4)[source]¶
@brief Returns the coordinate of the point at the intersection
of one segments defined by (p_1,p_2) and one line (p_3,p_4)
- fastwater.otm_gpl.geometry.get_triangle_area(point_1, point_2, point_3)[source]¶
Compute the area of a triangle
@param point_1 (2-uple) Coordinates of the first point of the triangle @param point_2 (2-uple) Coordinates of the second point of the triangle @param point_3 (2-uple) Coordinates of the third point of the triangle
@returns The area
- fastwater.otm_gpl.geometry.is_ccw(t_1, t_2, t_3)[source]¶
@brief Checks if the element is conterclockwise oriented or not
@param t_1 (tuple): coordinates of node 1 @param t_2 (tuple): coordinates of node 2 @param t_3 (tuple): coordinates of node 3
@return True if it is oriented counterclockwise, False otherwise
- fastwater.otm_gpl.geometry.is_close(p_1, p_2, size=5)[source]¶
Checks if two points are near each other
@param p_1 (2-uple) Coordianate of the first point @param p_2 (2-uple) Coordianate of the second point @param size (int) Additional offset for accuracy (10^-size)
- fastwater.otm_gpl.geometry.is_inside_poly(t_o, poly, close=True)[source]¶
Check if a point is in a polygon using Ray Casting Method
@param t_o (2-uple) Coordinates of the point @param poly (list) list of point of the polygon @param close (boolean) if true also check if the point is near the boundary of the polygon
@returns (boolean) True if inside