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
- P1: A point on the line. It is a vector that represents a specific point through which the line passes.
- ev: The direction vector of the line. This vector indicates the direction in which the line extends.
- p: The point to be mirrored. This is the point whose mirror image with respect to the line is to be calculated.
Output Results
- mp: The mirror point. This is the point that is the reflection of
p
across the line.
- do: The distance from the point
p
to the straight line, measured orthogonally with respect to the direction vector ev
.
- cp: The crossing point on the line. This is the point on the line that is closest to
p
.
- ov: The orthogonal vector from the point
p
to the crossing point cp
on the line.
Algorithm Steps
- Normalize the direction vector
ev
to ensure it has a unit length.
- 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.
- Use the reduced row echelon form (RREF) to solve the linear system that determines the distance
do
from p
to the line.
- Calculate the crossing point
cp
on the line by moving from p
along the orthogonal vector ov
by the distance do
.
- 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