mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 11:53:53 +00:00
simplify tree-grow-algorithm by strict focus on left/right steps;
This commit is contained in:
1 parent
54f8218764
commit
83e547bc4c
1 file changed
+2
-29
+2
-29
@@ -163,27 +163,9 @@ public class PathGeneratorTreeGrowWind extends PathGeneratorBase {
|
||||
return new TimedPositionImpl(nextTime, nextPosition);
|
||||
}
|
||||
|
||||
// use base direction to distinguish direction changes that do or don't require a turn
|
||||
char getBaseDirection(char direction) {
|
||||
char baseDirection = direction;
|
||||
|
||||
if (direction == 'M') {
|
||||
baseDirection = 'L';
|
||||
}
|
||||
if (direction == 'S') {
|
||||
baseDirection = 'R';
|
||||
}
|
||||
|
||||
return baseDirection;
|
||||
}
|
||||
|
||||
// check whether nextDirection is same base direction as previous direction, i.e. no turn
|
||||
boolean isSameDirection(char prevDirection, char nextDirection) {
|
||||
|
||||
char prevBaseDirection = this.getBaseDirection(prevDirection);
|
||||
char nextBaseDirection = this.getBaseDirection(nextDirection);
|
||||
|
||||
return ((nextBaseDirection == prevBaseDirection)||(prevBaseDirection == '0'));
|
||||
return ((nextDirection == prevDirection)||(prevDirection == '0'));
|
||||
}
|
||||
|
||||
// get path candidate measuring height towards (local, current-apparent) wind
|
||||
@@ -248,9 +230,8 @@ public class PathGeneratorTreeGrowWind extends PathGeneratorBase {
|
||||
|
||||
// extend path-string by step-direction
|
||||
String pathStr = path.path + nextDirection;
|
||||
char nextBaseDirection = this.getBaseDirection(nextDirection);
|
||||
|
||||
return (new PathCandidate(pathPos, reachedEnd, vrtDist, hrzDist, turnCount, pathStr, nextBaseDirection, appWind));
|
||||
return (new PathCandidate(pathPos, reachedEnd, vrtDist, hrzDist, turnCount, pathStr, nextDirection, appWind));
|
||||
}
|
||||
|
||||
|
||||
@@ -279,18 +260,10 @@ public class PathGeneratorTreeGrowWind extends PathGeneratorBase {
|
||||
newPathCand = getPathCandWind(path, 'L', timeStep, turnLoss, posStart, posEnd, tgtHeight);
|
||||
result.add(newPathCand);
|
||||
|
||||
// step wide left
|
||||
//newPathCand = getPathCandWind(path, 'M', timeStep, turnLoss, posStart, posEnd, tgtHeight);
|
||||
//result.add(newPathCand);
|
||||
|
||||
// step right
|
||||
newPathCand = getPathCandWind(path, 'R', timeStep, turnLoss, posStart, posEnd, tgtHeight);
|
||||
result.add(newPathCand);
|
||||
|
||||
// step wide right
|
||||
//newPathCand = getPathCandWind(path, 'S', timeStep, turnLoss, posStart, posEnd, tgtHeight);
|
||||
//result.add(newPathCand);
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user