feat: Add next node direction detection and path visualization improvements

Path Direction Detection (AGVPathfinder.cs):
- Added GetNextNodeByDirection() method to determine next node based on Forward/Backward direction
- Implements vector-based angle calculation for intelligent node selection
- Forward: selects node in continuous direction
- Backward: selects node in opposite direction
- Validates if selected direction matches path requirements

Logic additions at line 150-167:
- Detects next node for Forward and Backward directions
- Checks if backward movement aligns with path's next node
- Returns path with appropriate motor direction (ReverseDirection when applicable)

Improved Path Visualization (UnifiedAGVCanvas.Events.cs):
- Refined equilateral triangle arrows (8 pixels, symmetric)
- 50% transparency for purple path lines with 2x thickness
- Bidirectional path detection (darker color for repeated segments)
- Better visual distinction for calculated paths

Technical Details:
- Added System.Drawing using statement for PointF operations
- Added DirectionalPathfinder initialization
- Vector normalization for angle-based decisions
- Dot product calculation for direction similarity scoring

Result: AGV can now intelligently select next node based on current movement direction and validate path feasibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
backuppc
2025-10-24 17:38:03 +09:00
parent a6c4a967ad
commit 1d65531b11
2 changed files with 141 additions and 14 deletions

View File

@@ -154,39 +154,37 @@ namespace AGVNavigationCore.Controls
private void DrawDirectionArrow(Graphics g, Point point, double angle, AgvDirection direction)
{
var arrowSize = CONNECTION_ARROW_SIZE * 1.5; // 화살표 크기 증가
var arrowAngle = Math.PI / 6; // 30도
// 정삼각형 화살표 - 크기 축소 (8 픽셀)
var arrowSize = 8;
var cos = Math.Cos(angle);
var sin = Math.Sin(angle);
// 화살표 끝점 (방향)
// 정삼각형의 3개 점 계산
// 끝점 (방향 가르키는 점)
var arrowTipPoint = new Point(
(int)(point.X + arrowSize * Math.Cos(angle)),
(int)(point.Y + arrowSize * Math.Sin(angle))
);
// 화살표 좌측 점
// 좌측 점 (120도 차이)
var arrowPoint1 = new Point(
(int)(point.X - arrowSize * Math.Cos(angle - arrowAngle)),
(int)(point.Y - arrowSize * Math.Sin(angle - arrowAngle))
(int)(point.X + arrowSize * Math.Cos(angle + 2 * Math.PI / 3)),
(int)(point.Y + arrowSize * Math.Sin(angle + 2 * Math.PI / 3))
);
// 화살표 우측 점
// 우측 점 (240도 차이)
var arrowPoint2 = new Point(
(int)(point.X - arrowSize * Math.Cos(angle + arrowAngle)),
(int)(point.Y - arrowSize * Math.Sin(angle + arrowAngle))
(int)(point.X + arrowSize * Math.Cos(angle + 4 * Math.PI / 3)),
(int)(point.Y + arrowSize * Math.Sin(angle + 4 * Math.PI / 3))
);
var arrowColor = direction == AgvDirection.Forward ? Color.Blue : Color.Red;
var arrowBrush = new SolidBrush(arrowColor);
// 삼각형으로 화살표 그리기 (내부 채움)
// 삼각형으로 화살표 그리기 (내부 채움)
var trianglePoints = new Point[] { arrowTipPoint, arrowPoint1, arrowPoint2 };
g.FillPolygon(arrowBrush, trianglePoints);
// 윤곽선 그리기
var arrowPen = new Pen(arrowColor, 1.5f);
var arrowPen = new Pen(arrowColor, 1f);
g.DrawPolygon(arrowPen, trianglePoints);
arrowBrush.Dispose();