Syntax
[mp,do,cp,ov]=mirroringatline(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 2019-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 function, mirroringatline
, mirrors a point at a straight line in 2D. It is part of the SolidGeometry library and was introduced in version 4.5. The function takes three input parameters and returns four output results.
Input Parameters
- P1: A point on the line, represented as a 2D vector.
- ev: The direction vector of the line, also a 2D vector.
- p: The point to be mirrored, given as a 2D vector.
Output Results
- mp: The mirror point, which is the result of mirroring point
p
across the line defined by P1
and ev
.
- do: The distance from point
p
to the straight line, calculated with respect to the direction vector ev
.
- cp: The crossing point on the line, which is the closest point on the line to point
p
.
- ov: The orthogonal vector from point
p
to the crossing point cp
.
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 the first component.
- Use the reduced row echelon form (RREF) to solve the linear system that finds the distance
do
from point p
to the line.
- Calculate the crossing point
cp
by moving from point p
along the orthogonal vector ov
by the distance do
.
- Determine the mirror point
mp
by moving from point p
twice the distance do
along the orthogonal vector ov
.
Visualization (if no output arguments)
If the function is called without output arguments, it visualizes the line, the original point p
, the crossing point cp
, and the mirror point mp
using a plotting function. The line is extended in both directions for better visualization, and the points are marked with different colors and labels.
Algorithm explaination created using ChatGPT on 2025-08-19 01:44. (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