reflect_line_triangle

compas.geometry.reflect_line_triangle(line, triangle, tol=1e-06)[source]

Bounce a line of a reflection triangle.

Parameters
  • line ([point, point] | Line) – Two points defining the line.

  • triangle ([point, point, point]) – The triangle vertices.

  • tol (float, optional) – A tolerance for membership verification.

Returns

tuple[[float, float, float], [float, float, float]] – The reflected line defined by the intersection point of the line and triangle and the mirrored start point of the line with respect to a line perpendicular to the triangle through the intersection.

Notes

The direction of the line and triangle are important. The line is only reflected if it points towards the front of the triangle. This is true if the dot product of the direction vector of the line and the normal vector of the triangle is smaller than zero.

Examples

>>> triangle = [1.0, 0, 0], [-1.0, 0, 0], [0, 0, 1.0]
>>> line = [-1, 1, 0], [-0.5, 0.5, 0]
>>> reflect_line_triangle(line, triangle)
([0.0, 0.0, 0.0], [1.0, 1.0, 0.0])