dist2line

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 4.9, Creation date: 2020-01-08, Last change: 2025-09-14

mirrors a point at a straight line in 2D

Description

Should be renamed into PLmirroratline

See Also: PLcross2Lines , PLcrossCPLline , mirroringatline3D

Example Illustration

 missing image of dist2line(P1,ev,p)

Syntax

[mp,do,cp,ov]=dist2line(P1,ev,p)

Input Parameter

P1: Point on line
ev: direction vector
p: point to mirror

Output Parameter

mp: mirror point
do: distance to straight line (wrt to ev)
cp: crossing point on line
ov: orthogonal vector to straight line from p to cp

Examples


mirroringatline([0 0],+[-1 -6],[1 1])




Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This algorithm mirrors a point at a straight line in 2D. It is part of the SolidGeometry library and was introduced in version 4.9. The function is named dist2line and is designed to calculate the mirror point of a given point with respect to a line defined by a point and a direction vector.

Input Parameters

Output Results

Algorithm Steps

  1. Normalize the direction vector ev to ensure it has a unit length.
  2. Calculate the orthogonal vector ov to the line using the direction vector ev. This is done by swapping the components of ev and changing the sign of one component.
  3. Use the reduced row echelon form (RREF) to solve the linear system that determines the distance do from p to the line.
  4. Calculate the crossing point cp on the line by moving from p along the orthogonal vector ov by the distance do.
  5. Determine the mirror point mp by moving from p twice the distance do along the orthogonal vector ov.

Visualization

If no output arguments are specified, the function will plot the line, the original point p, the crossing point cp, and the mirror point mp using different colors and markers for visualization.

Algorithm explaination created using ChatGPT on 2025-08-19 01:36. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21