Syntax
NPL=PLroutefind(PL)
Input Parameter
Output Parameter
Copyright 2017-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 is designed to find a right-angle point list between a start and end point from an original point list (PL). It is part of the SG-Library and was created by Tim Lueth in 2017.
Input Parameters
- PL: The original point list, which is a matrix where each row represents a point in 2D space.
Output Results
- NPL: The new point list, which includes right-angle turns between the start and end points.
Algorithm Steps
- Extract the first point
p1
and the last point p2
from the point list PL
.
- Initialize a variable
gr
with a value of 5, which is used to adjust the points.
- Check if the x-coordinate of
p2
is less than that of p1
. If true, swap p1
and p2
and set a switch flag sw
to true; otherwise, set sw
to false.
- Calculate the direction vectors
e1
and e2
using the helper function domez
for the first and last segments of the point list, respectively.
- Adjust
p1
and p2
by adding gr
times the direction vectors e1
and e2
.
- Create a new point matrix
pm
that includes p1
, a right-angle turn point, and p2
.
- Construct the new point list
NPL
by combining the first point of PL
, the points in pm
, and the last point of PL
.
- Remove any straight-line segments from
NPL
using the function VLremstraightCVL
.
- If the switch flag
sw
is true, reverse the order of NPL
.
- If no output is requested, plot the original and new point lists using
SGfigure
and PLplot
.
Helper Function: domez
The domez
function calculates a unit direction vector along the axis of the largest component of a given vector A
. It finds the index of the maximum absolute value in A
, sets that component to 1 (or -1 depending on the sign), and zeros out the other components.
Algorithm explaination created using ChatGPT on 2025-08-18 23:02. (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