Geometry

LiquidRed.geometry.Point3d

alias of Point3D

LiquidRed.geometry.check_coplanar(v1, v2, v3, p)

Check if four points are coplanar using the scalar triple product.

Parameters:
  • v1 (Point3d) – Points defining a plane.

  • v2 (Point3d) – Points defining a plane.

  • v3 (Point3d) – Points defining a plane.

  • p (Point3d) – Point to test.

Returns:

True if coplanar (within tolerance).

Return type:

bool

LiquidRed.geometry.compute_surface_normal(v1, v2, v3)

Compute the unit normal vector of a surface defined by three points.

The normal is calculated using the cross product of two edges: (v2 - v1) × (v3 - v1).

Parameters:
Returns:

Normalized 3D normal vector.

Return type:

np.ndarray

Notes

  • If the triangle is degenerate (zero area), a default normal of [0, 0, 1] is returned.

LiquidRed.geometry.get_lambert_char(intensity)

Map a lighting intensity value to an ASCII character.

This function implements simple Lambertian shading by selecting a character from a predefined gradient.

Parameters:

intensity (float) – Lighting intensity in the range [0, 1].

Returns:

ASCII character representing brightness.

Return type:

str

Notes

  • Lower intensity → darker characters

  • Higher intensity → brighter characters

LiquidRed.geometry.point_position_wrt_line(a, b, x, y)

Compute the signed area (orientation test) of point (x,y) relative to the directed line from a to b.

This is equivalent to the 2D cross product and is commonly used in computational geometry (e.g., barycentric coordinates).

Parameters:
  • a (Point3d) – First point defining the line.

  • b (Point3d) – Second point defining the line.

  • x (ndarray) – x of the Point to test.

  • y (ndarray) – y of the Point to test.

Returns:

Signed value indicating position:

  • Positive → (x,y) is to the left of the line (a -> b)

  • Negative → (x,y) is to the right

  • Zero → (x,y) lies on the line

Return type:

ndarray

Notes

Only the x and y components are used.