Skip to main content
. 2015 Feb 2;15(2):3172–3203. doi: 10.3390/s150203172

Algorithm 1: Choice of the best point to add to a segment

begin
 vectorLength(point A; point B) ← length of the vector connecting the point A to the point B
 seg ← the current segment
 pt ← the last point added to the segment seg
 ListPoint ← adjacent points to the point pt
 PtF ← last point of the segment seg
 ptD ← (size(seg) > 5) ? 5th point before ptF: beginning of the segment seg
 maxValue ← 0
if ((ptD AND ptF) not NULL) then
  for each point pts of ListPoint do
   denominator ← vectorLength(pt ; pts)*vectorLength(ptD ; ptF)
   tempValue ← scalar product [pt ; pts] with [ptD ; ptF] / denominator
   if (tempValue > maxValue) then
    maxValue ← tempValue
    BestPoint ← pts