ddg.math.euclidean2d module

Planar Euclidean geometry utils.

ddg.math.euclidean2d.diagonals_intersection(a, b, c, d)[source]
ddg.math.euclidean2d.intersect_edges(a, b, c, d)[source]
ddg.math.euclidean2d.dual_quadrilateral(a, b, c, d)[source]
ddg.math.euclidean2d.distance_lines(a, v, b, w)[source]

Distance between the lines a + sv and b + tw.

ddg.math.euclidean2d.vertex_angle(x1, x2, x3)[source]

angle of (x1,x2,x3) on the left to the line (not the vector) only reliable for konvex quads!!!

ddg.math.euclidean2d.vertex_angle_with_sign(x1, x2, x3)[source]

like vertex_angle just with sign instead of +pi

ddg.math.euclidean2d.cyclic_order(points, center)[source]

determines the cyclic order of the points beginning with the first wrt the center maybe usefull for angle calculation in non-embedded case???

ddg.math.euclidean2d.circumcircle_center(x, y, z)[source]
ddg.math.euclidean2d.circumcircle_radius(x, y, z)[source]
ddg.math.euclidean2d.coordinates_on_circle_from_cross_ratio(x, x1, x2, q)[source]

get fourth point on a circle from real cross-ratio not exact with fractions right now…!!!

ddg.math.euclidean2d.triangle_area(a, b, c)[source]

Numerically stable version of Heron’s formula for the area of a tringagle with side lengths a,b,c.

ddg.math.euclidean2d.line2D(p1, p2)[source]

Gives the coefficients of the line equation describing the line through given points p1 and p2.

Parameters:
p1np.array([x1, y1])

Point p1 given by its Euclidean 2D coordinates in 2-dim array.

p2np.array([x2, y2])

Point p1 given by its Euclidean 2D coordinates in 2-dim array.

Returns:
[A, B, C]array of three floats

The coefficients of the line equation Ax + By = C describing the line through p1 and p2.

ddg.math.euclidean2d.intersection(l1, l2)[source]

Calculates the intersection of two lines that are given by coefficients of their line equations.

To do so the linear system Ax = b of the line equations is solved via numpy.linalg.solver.

Parameters:
l1, l2[float, float, float]

The two lines whose intersection shall be calculated. Both given by the coefficients of their line equations Ai*x + Bi*y = Ci where i=1,2.

Returns:
[x,y]np.array of two floats

The Euclidean 2D coordinates of the intersection point.

ddg.math.euclidean2d.intersectionCramer(l1, l2)[source]

Calculates the intersection of two lines that are given by coefficients of their line equations via Cramer’s rule.

Parameters:
l1, l2[float, float, float]

The two lines whose intersection shall be calculated. Both given by the coefficients of their line equations Ai*x + Bi*y = Ci where i=1,2.

Returns:
[x,y]array of two floats

The Euclidean 2D coordinates of the intersection point.

Raises:
ValueError

If the given lines do not intersect.

ddg.math.euclidean2d.intersection_in_barycentric_coords(a, b, p, q)[source]

Gives the intersection of two lines in barycentric coordinates relative to the given points which the lines run through.

Parameters:
a, bnp.array([float, float])

The two points the first line for intersecting runs through, given by their Euclidean 2D coordinates.

p, qnp.array([float, float])

The two points the second line for intersecting runs through, given by their Euclidean 2D coordinates.

Returns:
xnp.array[t1, s1, t2, s2] where ti, si float, i=1,2

The intersection of the lines given as the barycentric coordinates corresponding to solving the equation t1*a + s1*b = t2*p + s2*q.

Notes

We establish a homogeneous system and solve it via numpy.