fix: correct local bezier window constraints
This commit is contained in:
@@ -211,6 +211,23 @@ Assert-Equal $cornerSource.Count $cornerOutput.Count 'One local replacement must
|
||||
Assert-True (($cornerOutput[2].X -ne $cornerSource[2].X) -or ($cornerOutput[2].Y -ne $cornerSource[2].Y)) 'The corner sample must be replaced by cubic Bézier geometry.'
|
||||
Assert-PointBitwiseEqual $cornerSource[1] $cornerOutput[1] 'Bézier entry anchor must remain fixed.'
|
||||
Assert-PointBitwiseEqual $cornerSource[3] $cornerOutput[3] 'Bézier exit anchor must remain fixed.'
|
||||
$cornerChordLength = [Math]::Sqrt(
|
||||
[Math]::Pow($cornerSource[3].X - $cornerSource[1].X, 2.0) +
|
||||
[Math]::Pow($cornerSource[3].Y - $cornerSource[1].Y, 2.0))
|
||||
$cornerHandleLength = $cornerChordLength / 3.0
|
||||
$expectedCornerX =
|
||||
0.125 * $cornerSource[1].X +
|
||||
0.375 * ($cornerSource[1].X + $cornerHandleLength) +
|
||||
0.375 * $cornerSource[3].X +
|
||||
0.125 * $cornerSource[3].X
|
||||
$expectedCornerY =
|
||||
0.125 * $cornerSource[1].Y +
|
||||
0.375 * $cornerSource[1].Y +
|
||||
0.375 * ($cornerSource[3].Y - $cornerHandleLength) +
|
||||
0.125 * $cornerSource[3].Y
|
||||
$cornerInterpolated = Get-FirstInterpolatedPoint $cornerOutput
|
||||
Assert-Near $expectedCornerX $cornerInterpolated.X 0.000000000001 'Bézier control handles must use the local endpoint chord length for X geometry.'
|
||||
Assert-Near $expectedCornerY $cornerInterpolated.Y 0.000000000001 'Bézier control handles must use the local endpoint chord length for Y geometry.'
|
||||
|
||||
# Adjacent corner windows touch/overlap and must become one merged cubic replacement, not two sequential fits.
|
||||
$overlappingSource = @(
|
||||
@@ -227,6 +244,15 @@ Assert-PointBitwiseEqual $overlappingSource[4] $overlappingOutput[4] 'Merged Bé
|
||||
Assert-True (($overlappingOutput[2].X -ne $overlappingSource[2].X) -or ($overlappingOutput[2].Y -ne $overlappingSource[2].Y)) 'Merged window must replace the first interior corner sample.'
|
||||
Assert-True (($overlappingOutput[3].X -ne $overlappingSource[3].X) -or ($overlappingOutput[3].Y -ne $overlappingSource[3].Y)) 'Merged window must replace the second interior corner sample.'
|
||||
|
||||
# Safe bounded policy: decline an entire connected set when its merged interval exceeds the cap.
|
||||
# The two candidate windows below are each 0.20 m, but their merged 0.30 m interval must not
|
||||
# produce one over-length curve or be split into new unrequested joins.
|
||||
$overCapMergedOutput = @(Invoke-Smoothing @((New-DirectionSegment 0 $forward $overlappingSource)) 0.02 ([Math]::PI / 18.0) 0.20)[0].Points
|
||||
Assert-Equal 0 (Get-InterpolatedRunCount $overCapMergedOutput) 'An oversized connected Bézier window set must be declined instead of emitting an over-cap replacement.'
|
||||
for ($index = 0; $index -lt $overlappingSource.Count; $index++) {
|
||||
Assert-PointBitwiseEqual $overlappingSource[$index] $overCapMergedOutput[$index] 'Declining an oversized connected set must preserve its anchors.'
|
||||
}
|
||||
|
||||
# Samples outside a local window must remain bitwise unchanged rather than be globally re-fit.
|
||||
$isolatedSource = @(
|
||||
(New-Point 0.0 0.0 0.0 0.0),
|
||||
@@ -275,4 +301,19 @@ Assert-Equal 'RetryableInfeasible' (Get-PropertyValue $infeasible 'Status').ToSt
|
||||
Assert-True (-not (Get-PropertyValue $infeasible 'Succeeded')) 'An infeasible Bézier curve must not be executable.'
|
||||
Assert-Equal 0 (Get-PropertyValue $infeasible 'Segments').Count 'A retryable Bézier infeasibility must publish no executable geometry.'
|
||||
|
||||
# This nonuniform, offset window evaluates its only interior point at t=0.25 and local s=6.
|
||||
# A wrong global/index mapping would instead compare to s=5 and accept the 0.50 m clearance;
|
||||
# the required local-arc reference at s=6 must reject the roughly 0.65 m displacement.
|
||||
$nonuniformOffsetSource = @(
|
||||
(New-Point 0.0 0.0 0.0 0.0 0.50),
|
||||
(New-Point 1.0 0.0 4.0 0.0 0.50),
|
||||
(New-Point 2.0 0.0 5.0 0.0 0.50),
|
||||
(New-Point 3.0 0.0 6.0 0.0 0.50),
|
||||
(New-Point 3.0 1.0 9.0 ([Math]::PI / 2.0) 0.50),
|
||||
(New-Point 3.0 2.0 20.0 ([Math]::PI / 2.0) 0.50))
|
||||
$nonuniformOffsetInfeasible = Invoke-Candidate @((New-DirectionSegment 0 $forward $nonuniformOffsetSource)) 0.0 ([Math]::PI / 18.0) 5.0
|
||||
Assert-Equal 'RetryableInfeasible' (Get-PropertyValue $nonuniformOffsetInfeasible 'Status').ToString() 'A nonuniform offset window must use local arc-length mapping for retryable clearance rejection.'
|
||||
Assert-True (-not (Get-PropertyValue $nonuniformOffsetInfeasible 'Succeeded')) 'The nonuniform local-arc infeasibility must not be executable.'
|
||||
Assert-Equal 0 (Get-PropertyValue $nonuniformOffsetInfeasible 'Segments').Count 'The nonuniform local-arc infeasibility must publish no geometry.'
|
||||
|
||||
Write-Output 'Path smoothing local cubic Bézier checks passed.'
|
||||
|
||||
Reference in New Issue
Block a user