| | | 1 | | //======================================================================= |
| | | 2 | | // WideOrientedBox.CircleSlabSweep.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024–present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System; |
| | | 9 | | |
| | | 10 | | namespace FixedMathSharp.Geometry; |
| | | 11 | | |
| | | 12 | | /// <content> |
| | | 13 | | /// High-precision sweep tests between a circle and an oriented box slab, |
| | | 14 | | /// using wide fixed-point arithmetic to avoid overflow and precision loss. |
| | | 15 | | /// </content> |
| | | 16 | | internal static partial class WideOrientedBox |
| | | 17 | | { |
| | 1 | 18 | | private static readonly Signed192 SweepRawScale = Signed192.Signed(FixedMath.ONE_L); |
| | 1 | 19 | | private static readonly Signed192 SweepDoubleRawScale = Signed192.Signed(FixedMath.ONE_L * 2L); |
| | 1 | 20 | | private static readonly Signed192 SweepOneCoefficient = Signed192.Signed(1L); |
| | | 21 | | |
| | | 22 | | #region Nested Types |
| | | 23 | | |
| | | 24 | | private readonly struct RationalPointDistance |
| | | 25 | | { |
| | | 26 | | internal readonly Signed576 Denominator; |
| | | 27 | | internal readonly Signed832 SquaredDistance; |
| | | 28 | | |
| | | 29 | | internal RationalPointDistance( |
| | | 30 | | Signed576 denominator, |
| | | 31 | | Signed832 squaredDistance) |
| | | 32 | | { |
| | 16 | 33 | | Denominator = denominator; |
| | 16 | 34 | | SquaredDistance = squaredDistance; |
| | 16 | 35 | | } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | #endregion |
| | | 39 | | |
| | | 40 | | internal static bool TryGetCircleSlabSweepDistance( |
| | | 41 | | Vector3d center, |
| | | 42 | | FixedQuaternion orientation, |
| | | 43 | | Vector3d halfExtents, |
| | | 44 | | Vector3d slabStartCenter, |
| | | 45 | | Vector2d normalizedDirection, |
| | | 46 | | Fixed64 maxDistance, |
| | | 47 | | Fixed64 slabHalfThickness, |
| | | 48 | | Fixed64 radius, |
| | | 49 | | out Fixed64 distance) |
| | | 50 | | { |
| | 142 | 51 | | if (TryGetCircleSlabContact( |
| | 142 | 52 | | center, |
| | 142 | 53 | | orientation, |
| | 142 | 54 | | halfExtents, |
| | 142 | 55 | | slabStartCenter, |
| | 142 | 56 | | Fixed64.Zero, |
| | 142 | 57 | | slabHalfThickness, |
| | 142 | 58 | | radius, |
| | 142 | 59 | | out _)) |
| | | 60 | | { |
| | 1 | 61 | | distance = Fixed64.Zero; |
| | 1 | 62 | | return true; |
| | | 63 | | } |
| | | 64 | | |
| | 141 | 65 | | if (maxDistance == Fixed64.Zero) |
| | | 66 | | { |
| | 1 | 67 | | distance = default; |
| | 1 | 68 | | return false; |
| | | 69 | | } |
| | | 70 | | |
| | 140 | 71 | | WideRationalBasis3d basis = new(orientation); |
| | 140 | 72 | | Signed192 lowerY = WideArithmetic.SubtractSigned192( |
| | 140 | 73 | | Signed192.Raw(slabStartCenter.Y), |
| | 140 | 74 | | Signed192.Raw(slabHalfThickness)); |
| | 140 | 75 | | Signed192 upperY = WideArithmetic.AddSigned192( |
| | 140 | 76 | | Signed192.Raw(slabStartCenter.Y), |
| | 140 | 77 | | Signed192.Raw(slabHalfThickness)); |
| | 140 | 78 | | Span<SweepPlanarConstraint> constraints = |
| | 140 | 79 | | stackalloc SweepPlanarConstraint[16]; |
| | 140 | 80 | | if (!TryBuildCircleSlabProjectionConstraints( |
| | 140 | 81 | | center, |
| | 140 | 82 | | halfExtents, |
| | 140 | 83 | | basis, |
| | 140 | 84 | | lowerY, |
| | 140 | 85 | | upperY, |
| | 140 | 86 | | constraints, |
| | 140 | 87 | | out int constraintCount)) |
| | | 88 | | { |
| | 1 | 89 | | distance = default; |
| | 1 | 90 | | return false; |
| | | 91 | | } |
| | | 92 | | |
| | 139 | 93 | | Span<SweepRationalPoint> vertices = |
| | 139 | 94 | | stackalloc SweepRationalPoint[32]; |
| | 139 | 95 | | BuildCircleSlabProjectionVertices( |
| | 139 | 96 | | center, |
| | 139 | 97 | | halfExtents, |
| | 139 | 98 | | basis, |
| | 139 | 99 | | lowerY, |
| | 139 | 100 | | upperY, |
| | 139 | 101 | | vertices, |
| | 139 | 102 | | out int vertexCount); |
| | 139 | 103 | | Vector2d planarStart = new(slabStartCenter.X, slabStartCenter.Z); |
| | 139 | 104 | | bool found = false; |
| | 139 | 105 | | Fixed64 best = Fixed64.MaxValue; |
| | 3454 | 106 | | for (int index = 0; index < constraintCount; index++) |
| | | 107 | | { |
| | 1588 | 108 | | if (!TryGetExpandedEdgeSweepDistance( |
| | 1588 | 109 | | constraints, |
| | 1588 | 110 | | constraintCount, |
| | 1588 | 111 | | index, |
| | 1588 | 112 | | planarStart, |
| | 1588 | 113 | | normalizedDirection, |
| | 1588 | 114 | | maxDistance, |
| | 1588 | 115 | | radius, |
| | 1588 | 116 | | out Fixed64 candidate)) |
| | | 117 | | { |
| | | 118 | | continue; |
| | | 119 | | } |
| | 134 | 120 | | best = FixedMath.Min(best, candidate); |
| | 134 | 121 | | found = true; |
| | | 122 | | } |
| | | 123 | | |
| | 2422 | 124 | | for (int index = 0; index < vertexCount; index++) |
| | | 125 | | { |
| | 1072 | 126 | | if (!TryGetRationalPointSweepDistance( |
| | 1072 | 127 | | vertices[index], |
| | 1072 | 128 | | planarStart, |
| | 1072 | 129 | | normalizedDirection, |
| | 1072 | 130 | | maxDistance, |
| | 1072 | 131 | | radius, |
| | 1072 | 132 | | out Fixed64 candidate)) |
| | | 133 | | { |
| | | 134 | | continue; |
| | | 135 | | } |
| | | 136 | | |
| | 4 | 137 | | best = FixedMath.Min(best, candidate); |
| | 4 | 138 | | found = true; |
| | | 139 | | } |
| | | 140 | | |
| | 139 | 141 | | distance = found ? best : default; |
| | 139 | 142 | | return found; |
| | | 143 | | } |
| | | 144 | | |
| | | 145 | | internal static Fixed64 GetCircleSlabSeparationLowerBound( |
| | | 146 | | Vector3d center, |
| | | 147 | | FixedQuaternion orientation, |
| | | 148 | | Vector3d halfExtents, |
| | | 149 | | Vector3d slabCenter, |
| | | 150 | | Fixed64 slabHalfThickness, |
| | | 151 | | Fixed64 radius) |
| | | 152 | | { |
| | 9 | 153 | | WideRationalBasis3d basis = new(orientation); |
| | 9 | 154 | | Signed192 lowerY = WideArithmetic.SubtractSigned192( |
| | 9 | 155 | | Signed192.Raw(slabCenter.Y), |
| | 9 | 156 | | Signed192.Raw(slabHalfThickness)); |
| | 9 | 157 | | Signed192 upperY = WideArithmetic.AddSigned192( |
| | 9 | 158 | | Signed192.Raw(slabCenter.Y), |
| | 9 | 159 | | Signed192.Raw(slabHalfThickness)); |
| | 9 | 160 | | Span<SweepPlanarConstraint> constraints = |
| | 9 | 161 | | stackalloc SweepPlanarConstraint[16]; |
| | 9 | 162 | | if (!TryBuildCircleSlabProjectionConstraints( |
| | 9 | 163 | | center, |
| | 9 | 164 | | halfExtents, |
| | 9 | 165 | | basis, |
| | 9 | 166 | | lowerY, |
| | 9 | 167 | | upperY, |
| | 9 | 168 | | constraints, |
| | 9 | 169 | | out int count)) |
| | | 170 | | { |
| | 2 | 171 | | return GetCircleSlabVerticalSeparationLowerBound( |
| | 2 | 172 | | center, |
| | 2 | 173 | | halfExtents, |
| | 2 | 174 | | basis, |
| | 2 | 175 | | lowerY, |
| | 2 | 176 | | upperY); |
| | | 177 | | } |
| | | 178 | | |
| | 7 | 179 | | Vector2d planarCenter = new(slabCenter.X, slabCenter.Z); |
| | 7 | 180 | | Fixed64 lowerBound = Fixed64.Zero; |
| | 7 | 181 | | bool hasPlanarViolation = false; |
| | 7 | 182 | | bool hasClosestEdgeFeature = false; |
| | 54 | 183 | | for (int index = 0; index < count; index++) |
| | | 184 | | { |
| | 22 | 185 | | SweepPlanarConstraint constraint = constraints[index]; |
| | 22 | 186 | | Signed576 violation = WideArithmetic.SubtractSigned576( |
| | 22 | 187 | | GetSweepProjection(constraint, planarCenter), |
| | 22 | 188 | | constraint.K); |
| | 22 | 189 | | if (violation.Sign <= 0) |
| | | 190 | | continue; |
| | | 191 | | |
| | 10 | 192 | | hasPlanarViolation = true; |
| | 10 | 193 | | Signed576 normalSquared = WideArithmetic.AddSigned576( |
| | 10 | 194 | | WideArithmetic.MultiplySigned320( |
| | 10 | 195 | | constraint.A, |
| | 10 | 196 | | constraint.A), |
| | 10 | 197 | | WideArithmetic.MultiplySigned320( |
| | 10 | 198 | | constraint.C, |
| | 10 | 199 | | constraint.C)); |
| | 10 | 200 | | Signed576 normalFloor = WideArithmetic.GetFloorSquareRoot( |
| | 10 | 201 | | Signed704.ExtendValue(normalSquared)); |
| | 10 | 202 | | Signed832 floorSquared = |
| | 10 | 203 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 10 | 204 | | normalFloor, |
| | 10 | 205 | | normalFloor); |
| | 10 | 206 | | Signed832 remainderSign = WideArithmetic.SubtractSigned832( |
| | 10 | 207 | | floorSquared, |
| | 10 | 208 | | Signed832.ExtendValue(normalSquared)); |
| | 10 | 209 | | long ceilingIncrementRaw = |
| | 10 | 210 | | (long)(remainderSign.Word12 >> 63); |
| | 10 | 211 | | normalFloor = WideArithmetic.AddSigned576( |
| | 10 | 212 | | normalFloor, |
| | 10 | 213 | | Signed576.ExtendValue( |
| | 10 | 214 | | Signed320.ExtendValue( |
| | 10 | 215 | | Signed192.Signed( |
| | 10 | 216 | | ceilingIncrementRaw)))); |
| | | 217 | | |
| | 10 | 218 | | Fixed64 axisDistance = Fixed64.GetNonNegativeRawRatioFloor( |
| | 10 | 219 | | Signed704.ExtendValue(violation), |
| | 10 | 220 | | Signed704.ExtendValue(normalFloor)); |
| | 10 | 221 | | Fixed64 candidate = axisDistance > radius |
| | 10 | 222 | | ? axisDistance - radius |
| | 10 | 223 | | : Fixed64.Zero; |
| | 10 | 224 | | if (candidate > lowerBound) |
| | 6 | 225 | | lowerBound = candidate; |
| | | 226 | | |
| | 10 | 227 | | if (IsClosestProjectionOnConstraint( |
| | 10 | 228 | | constraints, |
| | 10 | 229 | | count, |
| | 10 | 230 | | index, |
| | 10 | 231 | | planarCenter, |
| | 10 | 232 | | violation, |
| | 10 | 233 | | Signed320.NarrowValue(normalSquared))) |
| | | 234 | | { |
| | 2 | 235 | | hasClosestEdgeFeature = true; |
| | | 236 | | // This valid orthogonal projection is the closest point of |
| | | 237 | | // the convex projection. Every remaining half-space distance |
| | | 238 | | // is therefore bounded by the candidate already retained. |
| | 2 | 239 | | break; |
| | | 240 | | } |
| | | 241 | | } |
| | | 242 | | |
| | 7 | 243 | | if (hasPlanarViolation && !hasClosestEdgeFeature) |
| | | 244 | | { |
| | 4 | 245 | | Fixed64 vertexDistance = |
| | 4 | 246 | | GetClosestProjectionVertexDistanceLowerBound( |
| | 4 | 247 | | center, |
| | 4 | 248 | | halfExtents, |
| | 4 | 249 | | basis, |
| | 4 | 250 | | lowerY, |
| | 4 | 251 | | upperY, |
| | 4 | 252 | | planarCenter); |
| | 4 | 253 | | Fixed64 vertexGap = vertexDistance > radius |
| | 4 | 254 | | ? vertexDistance - radius |
| | 4 | 255 | | : Fixed64.Zero; |
| | 4 | 256 | | if (vertexGap > lowerBound) |
| | 3 | 257 | | lowerBound = vertexGap; |
| | | 258 | | } |
| | | 259 | | |
| | 7 | 260 | | return lowerBound; |
| | | 261 | | } |
| | | 262 | | |
| | | 263 | | private static bool IsClosestProjectionOnConstraint( |
| | | 264 | | ReadOnlySpan<SweepPlanarConstraint> constraints, |
| | | 265 | | int constraintCount, |
| | | 266 | | int constraintIndex, |
| | | 267 | | Vector2d point, |
| | | 268 | | Signed576 violation, |
| | | 269 | | Signed320 normalSquared) |
| | | 270 | | { |
| | 10 | 271 | | SweepPlanarConstraint constraint = constraints[constraintIndex]; |
| | 52 | 272 | | for (int index = 0; index < constraintCount; index++) |
| | | 273 | | { |
| | 24 | 274 | | SweepPlanarConstraint candidate = constraints[index]; |
| | 24 | 275 | | Signed576 candidateViolation = |
| | 24 | 276 | | WideArithmetic.SubtractSigned576( |
| | 24 | 277 | | GetSweepProjection(candidate, point), |
| | 24 | 278 | | candidate.K); |
| | 24 | 279 | | Signed320 normalDot = Signed320.NarrowValue( |
| | 24 | 280 | | WideArithmetic.AddSigned576( |
| | 24 | 281 | | WideArithmetic.MultiplySigned320( |
| | 24 | 282 | | candidate.A, |
| | 24 | 283 | | constraint.A), |
| | 24 | 284 | | WideArithmetic.MultiplySigned320( |
| | 24 | 285 | | candidate.C, |
| | 24 | 286 | | constraint.C))); |
| | 24 | 287 | | Signed704 projectedViolation = |
| | 24 | 288 | | WideArithmetic.SubtractSigned704( |
| | 24 | 289 | | WideArithmetic.MultiplySigned576ToSigned704( |
| | 24 | 290 | | candidateViolation, |
| | 24 | 291 | | normalSquared), |
| | 24 | 292 | | WideArithmetic.MultiplySigned576ToSigned704( |
| | 24 | 293 | | violation, |
| | 24 | 294 | | normalDot)); |
| | 24 | 295 | | if (projectedViolation.Sign > 0) |
| | 8 | 296 | | return false; |
| | | 297 | | } |
| | | 298 | | |
| | 2 | 299 | | return true; |
| | | 300 | | } |
| | | 301 | | |
| | | 302 | | private static Fixed64 GetClosestProjectionVertexDistanceLowerBound( |
| | | 303 | | Vector3d center, |
| | | 304 | | Vector3d halfExtents, |
| | | 305 | | WideRationalBasis3d basis, |
| | | 306 | | Signed192 lowerY, |
| | | 307 | | Signed192 upperY, |
| | | 308 | | Vector2d point) |
| | | 309 | | { |
| | 4 | 310 | | Span<SweepRationalPoint> vertices = |
| | 4 | 311 | | stackalloc SweepRationalPoint[32]; |
| | 4 | 312 | | BuildCircleSlabProjectionVertices( |
| | 4 | 313 | | center, |
| | 4 | 314 | | halfExtents, |
| | 4 | 315 | | basis, |
| | 4 | 316 | | lowerY, |
| | 4 | 317 | | upperY, |
| | 4 | 318 | | vertices, |
| | 4 | 319 | | out int vertexCount); |
| | | 320 | | // The caller already proved that the finite box/slab intersection is |
| | | 321 | | // nonempty, so its compact planar projection has at least one vertex. |
| | 4 | 322 | | RationalPointDistance closest = |
| | 4 | 323 | | GetRationalPointDistance(vertices[0], point); |
| | 32 | 324 | | for (int index = 1; index < vertexCount; index++) |
| | | 325 | | { |
| | 12 | 326 | | RationalPointDistance candidate = |
| | 12 | 327 | | GetRationalPointDistance(vertices[index], point); |
| | 12 | 328 | | if (CompareRationalPointDistances(candidate, closest) < 0) |
| | 8 | 329 | | closest = candidate; |
| | | 330 | | } |
| | | 331 | | |
| | 4 | 332 | | return GetRationalPointDistanceLowerBound(closest); |
| | | 333 | | } |
| | | 334 | | |
| | | 335 | | private static RationalPointDistance GetRationalPointDistance( |
| | | 336 | | SweepRationalPoint point, |
| | | 337 | | Vector2d reference) |
| | | 338 | | { |
| | 16 | 339 | | Signed576 deltaX = WideArithmetic.SubtractSigned576( |
| | 16 | 340 | | WideArithmetic.MultiplySigned576( |
| | 16 | 341 | | point.Denominator, |
| | 16 | 342 | | Signed192.Raw(reference.X)), |
| | 16 | 343 | | point.X); |
| | 16 | 344 | | Signed576 deltaZ = WideArithmetic.SubtractSigned576( |
| | 16 | 345 | | WideArithmetic.MultiplySigned576( |
| | 16 | 346 | | point.Denominator, |
| | 16 | 347 | | Signed192.Raw(reference.Y)), |
| | 16 | 348 | | point.Z); |
| | 16 | 349 | | Signed832 squaredDistance = WideArithmetic.AddSigned832( |
| | 16 | 350 | | WideArithmetic.MultiplySigned576ToSigned832(deltaX, deltaX), |
| | 16 | 351 | | WideArithmetic.MultiplySigned576ToSigned832(deltaZ, deltaZ)); |
| | 16 | 352 | | return new RationalPointDistance( |
| | 16 | 353 | | point.Denominator, |
| | 16 | 354 | | squaredDistance); |
| | | 355 | | } |
| | | 356 | | |
| | | 357 | | private static int CompareRationalPointDistances( |
| | | 358 | | RationalPointDistance first, |
| | | 359 | | RationalPointDistance second) |
| | | 360 | | { |
| | 12 | 361 | | Signed832 firstDenominatorSquared = |
| | 12 | 362 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 12 | 363 | | first.Denominator, |
| | 12 | 364 | | first.Denominator); |
| | 12 | 365 | | Signed832 secondDenominatorSquared = |
| | 12 | 366 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 12 | 367 | | second.Denominator, |
| | 12 | 368 | | second.Denominator); |
| | 12 | 369 | | Span<ulong> firstSquaredMagnitude = stackalloc ulong[13]; |
| | 12 | 370 | | Span<ulong> secondSquaredMagnitude = stackalloc ulong[13]; |
| | 12 | 371 | | Span<ulong> firstDenominatorMagnitude = stackalloc ulong[13]; |
| | 12 | 372 | | Span<ulong> secondDenominatorMagnitude = stackalloc ulong[13]; |
| | 12 | 373 | | WideArithmetic.GetMagnitude( |
| | 12 | 374 | | first.SquaredDistance, |
| | 12 | 375 | | firstSquaredMagnitude); |
| | 12 | 376 | | WideArithmetic.GetMagnitude( |
| | 12 | 377 | | second.SquaredDistance, |
| | 12 | 378 | | secondSquaredMagnitude); |
| | 12 | 379 | | WideArithmetic.GetMagnitude( |
| | 12 | 380 | | firstDenominatorSquared, |
| | 12 | 381 | | firstDenominatorMagnitude); |
| | 12 | 382 | | WideArithmetic.GetMagnitude( |
| | 12 | 383 | | secondDenominatorSquared, |
| | 12 | 384 | | secondDenominatorMagnitude); |
| | 12 | 385 | | Span<ulong> left = |
| | 12 | 386 | | stackalloc ulong[TriangleSweepMagnitudeWords]; |
| | 12 | 387 | | Span<ulong> right = |
| | 12 | 388 | | stackalloc ulong[TriangleSweepMagnitudeWords]; |
| | 12 | 389 | | WideArithmetic.MultiplyMagnitudes( |
| | 12 | 390 | | firstSquaredMagnitude, |
| | 12 | 391 | | secondDenominatorMagnitude, |
| | 12 | 392 | | left); |
| | 12 | 393 | | WideArithmetic.MultiplyMagnitudes( |
| | 12 | 394 | | secondSquaredMagnitude, |
| | 12 | 395 | | firstDenominatorMagnitude, |
| | 12 | 396 | | right); |
| | 12 | 397 | | return WideArithmetic.CompareMagnitudeEqualLength(left, right); |
| | | 398 | | } |
| | | 399 | | |
| | | 400 | | private static Fixed64 GetRationalPointDistanceLowerBound( |
| | | 401 | | RationalPointDistance distance) |
| | | 402 | | { |
| | 4 | 403 | | long low = 0L; |
| | 4 | 404 | | long high = Fixed64.MaxValue.m_rawValue; |
| | 256 | 405 | | while (low < high) |
| | | 406 | | { |
| | 252 | 407 | | long difference = high - low; |
| | 252 | 408 | | long middle = |
| | 252 | 409 | | low + (difference >> 1) + (difference & 1L); |
| | 252 | 410 | | Signed576 scaledDistance = WideArithmetic.MultiplySigned576( |
| | 252 | 411 | | distance.Denominator, |
| | 252 | 412 | | Signed192.Signed(middle)); |
| | 252 | 413 | | Signed832 squaredCandidate = |
| | 252 | 414 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 252 | 415 | | scaledDistance, |
| | 252 | 416 | | scaledDistance); |
| | 252 | 417 | | if (WideArithmetic.SubtractSigned832( |
| | 252 | 418 | | squaredCandidate, |
| | 252 | 419 | | distance.SquaredDistance).Sign <= 0) |
| | | 420 | | { |
| | 58 | 421 | | low = middle; |
| | | 422 | | } |
| | | 423 | | else |
| | | 424 | | { |
| | 194 | 425 | | high = middle - 1L; |
| | | 426 | | } |
| | | 427 | | } |
| | | 428 | | |
| | 4 | 429 | | return Fixed64.FromRaw(low); |
| | | 430 | | } |
| | | 431 | | |
| | | 432 | | private static Fixed64 GetCircleSlabVerticalSeparationLowerBound( |
| | | 433 | | Vector3d center, |
| | | 434 | | Vector3d halfExtents, |
| | | 435 | | WideRationalBasis3d basis, |
| | | 436 | | Signed192 lowerY, |
| | | 437 | | Signed192 upperY) |
| | | 438 | | { |
| | 2 | 439 | | Signed320 boxRadius = GetExtentNumerator( |
| | 2 | 440 | | basis.Xy, |
| | 2 | 441 | | basis.Yy, |
| | 2 | 442 | | basis.Zy, |
| | 2 | 443 | | halfExtents); |
| | 2 | 444 | | Signed320 boxCenter = WideArithmetic.MultiplySigned192( |
| | 2 | 445 | | Signed192.Raw(center.Y), |
| | 2 | 446 | | basis.Denominator); |
| | 2 | 447 | | Signed320 boxMinimum = |
| | 2 | 448 | | WideArithmetic.SubtractSigned320(boxCenter, boxRadius); |
| | 2 | 449 | | Signed320 boxMaximum = |
| | 2 | 450 | | WideArithmetic.AddSigned320(boxCenter, boxRadius); |
| | 2 | 451 | | Signed320 slabMinimum = |
| | 2 | 452 | | WideArithmetic.MultiplySigned192(lowerY, basis.Denominator); |
| | 2 | 453 | | Signed320 slabMaximum = |
| | 2 | 454 | | WideArithmetic.MultiplySigned192(upperY, basis.Denominator); |
| | 2 | 455 | | Signed320 gap = CompareSigned(boxMaximum, slabMinimum) < 0 |
| | 2 | 456 | | ? WideArithmetic.SubtractSigned320(slabMinimum, boxMaximum) |
| | 2 | 457 | | : WideArithmetic.SubtractSigned320(boxMinimum, slabMaximum); |
| | 2 | 458 | | return Fixed64.GetNonNegativeRawRatioFloor( |
| | 2 | 459 | | Signed704.ExtendValue( |
| | 2 | 460 | | Signed576.ExtendValue(gap)), |
| | 2 | 461 | | Signed704.ExtendValue( |
| | 2 | 462 | | Signed576.ExtendValue( |
| | 2 | 463 | | Signed320.ExtendValue( |
| | 2 | 464 | | basis.Denominator)))); |
| | | 465 | | } |
| | | 466 | | |
| | | 467 | | private static bool TryGetExpandedEdgeSweepDistance( |
| | | 468 | | ReadOnlySpan<SweepPlanarConstraint> constraints, |
| | | 469 | | int constraintCount, |
| | | 470 | | int constraintIndex, |
| | | 471 | | Vector2d start, |
| | | 472 | | Vector2d direction, |
| | | 473 | | Fixed64 maxDistance, |
| | | 474 | | Fixed64 radius, |
| | | 475 | | out Fixed64 distance) |
| | | 476 | | { |
| | 1588 | 477 | | SweepPlanarConstraint edge = constraints[constraintIndex]; |
| | 1588 | 478 | | Signed576 startViolation = WideArithmetic.SubtractSigned576( |
| | 1588 | 479 | | GetSweepProjection(edge, start), |
| | 1588 | 480 | | edge.K); |
| | 1588 | 481 | | if (startViolation.Sign <= 0) |
| | | 482 | | { |
| | 930 | 483 | | distance = default; |
| | 930 | 484 | | return false; |
| | | 485 | | } |
| | | 486 | | |
| | 658 | 487 | | Signed576 normalSquared = WideArithmetic.AddSigned576( |
| | 658 | 488 | | WideArithmetic.MultiplySigned320(edge.A, edge.A), |
| | 658 | 489 | | WideArithmetic.MultiplySigned320(edge.C, edge.C)); |
| | 658 | 490 | | Signed320 radiusSquared = |
| | 658 | 491 | | WideArithmetic.MultiplySigned192(Signed192.Raw(radius), Signed192.Raw(radius)); |
| | 658 | 492 | | Signed832 expandedSquared = |
| | 658 | 493 | | WideArithmetic.MultiplyNonNegativeToSigned832( |
| | 658 | 494 | | Signed832.ExtendValue( |
| | 658 | 495 | | Signed576.ExtendValue(radiusSquared)), |
| | 658 | 496 | | Signed320.NarrowValue(normalSquared)); |
| | 658 | 497 | | Signed832 startSquared = |
| | 658 | 498 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 658 | 499 | | startViolation, |
| | 658 | 500 | | startViolation); |
| | 658 | 501 | | if (WideArithmetic.SubtractSigned832( |
| | 658 | 502 | | startSquared, |
| | 658 | 503 | | expandedSquared).Sign <= 0) |
| | | 504 | | { |
| | 4 | 505 | | distance = default; |
| | 4 | 506 | | return false; |
| | | 507 | | } |
| | | 508 | | |
| | 654 | 509 | | Signed576 velocity = GetSweepProjection(edge, direction); |
| | 654 | 510 | | if (velocity.Sign >= 0 |
| | 654 | 511 | | || CompareExpandedEdgeAt( |
| | 654 | 512 | | startViolation, |
| | 654 | 513 | | velocity, |
| | 654 | 514 | | normalSquared, |
| | 654 | 515 | | radius, |
| | 654 | 516 | | Signed192.Signed(maxDistance.m_rawValue), |
| | 654 | 517 | | SweepRawScale) > 0) |
| | | 518 | | { |
| | 2 | 519 | | distance = default; |
| | 2 | 520 | | return false; |
| | | 521 | | } |
| | | 522 | | |
| | 652 | 523 | | long maxRaw = maxDistance.m_rawValue; |
| | | 524 | | // The public contract has already rejected a zero maximum distance. |
| | 652 | 525 | | long high = maxRaw - 1L; |
| | 652 | 526 | | if (CompareExpandedEdgeAtHalf( |
| | 652 | 527 | | startViolation, |
| | 652 | 528 | | velocity, |
| | 652 | 529 | | normalSquared, |
| | 652 | 530 | | radius, |
| | 652 | 531 | | high) > 0) |
| | | 532 | | { |
| | 1 | 533 | | distance = maxDistance; |
| | | 534 | | } |
| | | 535 | | else |
| | | 536 | | { |
| | 651 | 537 | | long low = 0L; |
| | 24076 | 538 | | while (low < high) |
| | | 539 | | { |
| | 23425 | 540 | | long middle = low + ((high - low) >> 1); |
| | 23425 | 541 | | if (CompareExpandedEdgeAtHalf( |
| | 23425 | 542 | | startViolation, |
| | 23425 | 543 | | velocity, |
| | 23425 | 544 | | normalSquared, |
| | 23425 | 545 | | radius, |
| | 23425 | 546 | | middle) <= 0) |
| | | 547 | | { |
| | 12368 | 548 | | high = middle; |
| | | 549 | | } |
| | | 550 | | else |
| | | 551 | | { |
| | 11057 | 552 | | low = middle + 1L; |
| | | 553 | | } |
| | | 554 | | } |
| | | 555 | | |
| | 651 | 556 | | int midpointComparison = CompareExpandedEdgeAtHalf( |
| | 651 | 557 | | startViolation, |
| | 651 | 558 | | velocity, |
| | 651 | 559 | | normalSquared, |
| | 651 | 560 | | radius, |
| | 651 | 561 | | low); |
| | 651 | 562 | | distance = Fixed64.FromRaw( |
| | 651 | 563 | | low + GetHalfToEvenIncrement(midpointComparison, low)); |
| | | 564 | | } |
| | | 565 | | |
| | 652 | 566 | | return IsRoundedEdgeFeatureValid( |
| | 652 | 567 | | constraints, |
| | 652 | 568 | | constraintCount, |
| | 652 | 569 | | constraintIndex, |
| | 652 | 570 | | start, |
| | 652 | 571 | | direction, |
| | 652 | 572 | | distance, |
| | 652 | 573 | | radius); |
| | | 574 | | } |
| | | 575 | | |
| | | 576 | | private static int CompareExpandedEdgeAtHalf( |
| | | 577 | | Signed576 startViolation, |
| | | 578 | | Signed576 velocity, |
| | | 579 | | Signed576 normalSquared, |
| | | 580 | | Fixed64 radius, |
| | | 581 | | long lowerRaw) |
| | | 582 | | { |
| | 24728 | 583 | | Signed192 lower = Signed192.Signed(lowerRaw); |
| | 24728 | 584 | | Signed192 midpoint = WideArithmetic.AddSigned192( |
| | 24728 | 585 | | WideArithmetic.AddSigned192(lower, lower), |
| | 24728 | 586 | | SweepOneCoefficient); |
| | 24728 | 587 | | return CompareExpandedEdgeAt( |
| | 24728 | 588 | | startViolation, |
| | 24728 | 589 | | velocity, |
| | 24728 | 590 | | normalSquared, |
| | 24728 | 591 | | radius, |
| | 24728 | 592 | | midpoint, |
| | 24728 | 593 | | SweepDoubleRawScale); |
| | | 594 | | } |
| | | 595 | | |
| | | 596 | | private static int CompareExpandedEdgeAt( |
| | | 597 | | Signed576 startViolation, |
| | | 598 | | Signed576 velocity, |
| | | 599 | | Signed576 normalSquared, |
| | | 600 | | Fixed64 radius, |
| | | 601 | | Signed192 timeNumerator, |
| | | 602 | | Signed192 timeDenominator) |
| | | 603 | | { |
| | 25380 | 604 | | Signed576 left = WideArithmetic.AddSigned576( |
| | 25380 | 605 | | WideArithmetic.MultiplySigned576( |
| | 25380 | 606 | | startViolation, |
| | 25380 | 607 | | timeDenominator), |
| | 25380 | 608 | | WideArithmetic.MultiplySigned576( |
| | 25380 | 609 | | velocity, |
| | 25380 | 610 | | timeNumerator)); |
| | 25380 | 611 | | if (left.Sign <= 0) |
| | 3025 | 612 | | return -1; |
| | | 613 | | |
| | 22355 | 614 | | Signed832 leftSquared = |
| | 22355 | 615 | | WideArithmetic.MultiplySigned576ToSigned832(left, left); |
| | 22355 | 616 | | Signed320 scaledRadius = WideArithmetic.MultiplySigned192( |
| | 22355 | 617 | | Signed192.Raw(radius), |
| | 22355 | 618 | | timeDenominator); |
| | 22355 | 619 | | Signed832 rightSquared = |
| | 22355 | 620 | | WideArithmetic.MultiplyNonNegativeToSigned832( |
| | 22355 | 621 | | Signed832.ExtendValue( |
| | 22355 | 622 | | WideArithmetic.MultiplySigned320( |
| | 22355 | 623 | | scaledRadius, |
| | 22355 | 624 | | scaledRadius)), |
| | 22355 | 625 | | Signed320.NarrowValue(normalSquared)); |
| | 22355 | 626 | | return WideArithmetic.SubtractSigned832( |
| | 22355 | 627 | | leftSquared, |
| | 22355 | 628 | | rightSquared).Sign; |
| | | 629 | | } |
| | | 630 | | |
| | | 631 | | private static bool IsRoundedEdgeFeatureValid( |
| | | 632 | | ReadOnlySpan<SweepPlanarConstraint> constraints, |
| | | 633 | | int constraintCount, |
| | | 634 | | int constraintIndex, |
| | | 635 | | Vector2d start, |
| | | 636 | | Vector2d direction, |
| | | 637 | | Fixed64 distance, |
| | | 638 | | Fixed64 radius) |
| | | 639 | | { |
| | 652 | 640 | | SweepPlanarConstraint edge = constraints[constraintIndex]; |
| | 652 | 641 | | Vector2d normal = WideNormalization.GetNormalized( |
| | 652 | 642 | | Signed576.ExtendValue(edge.A), |
| | 652 | 643 | | Signed576.ExtendValue(edge.C)); |
| | 652 | 644 | | Vector2d radial = normal * radius; |
| | 9080 | 645 | | for (int index = 0; index < constraintCount; index++) |
| | | 646 | | { |
| | 4406 | 647 | | SweepPlanarConstraint candidate = constraints[index]; |
| | 4406 | 648 | | Signed576 startViolation = WideArithmetic.SubtractSigned576( |
| | 4406 | 649 | | WideArithmetic.SubtractSigned576( |
| | 4406 | 650 | | GetSweepProjection(candidate, start), |
| | 4406 | 651 | | GetSweepProjection(candidate, radial)), |
| | 4406 | 652 | | candidate.K); |
| | 4406 | 653 | | Signed576 violation = WideArithmetic.AddSigned576( |
| | 4406 | 654 | | WideArithmetic.MultiplySigned576( |
| | 4406 | 655 | | startViolation, |
| | 4406 | 656 | | SweepRawScale), |
| | 4406 | 657 | | WideArithmetic.MultiplySigned576( |
| | 4406 | 658 | | GetSweepProjection(candidate, direction), |
| | 4406 | 659 | | Signed192.Raw(distance))); |
| | 4406 | 660 | | Signed320 coefficientMagnitude = WideArithmetic.AddSigned320( |
| | 4406 | 661 | | GetMagnitude(candidate.A), |
| | 4406 | 662 | | GetMagnitude(candidate.C)); |
| | 4406 | 663 | | Signed576 oneRawTolerance = WideArithmetic.MultiplySigned576( |
| | 4406 | 664 | | WideArithmetic.MultiplySigned320( |
| | 4406 | 665 | | coefficientMagnitude, |
| | 4406 | 666 | | Signed320.ExtendValue( |
| | 4406 | 667 | | Signed192.Raw(Fixed64.MinIncrement))), |
| | 4406 | 668 | | SweepRawScale); |
| | 4406 | 669 | | if (CompareSigned(violation, oneRawTolerance) > 0) |
| | 518 | 670 | | return false; |
| | | 671 | | } |
| | | 672 | | |
| | 134 | 673 | | return true; |
| | | 674 | | } |
| | | 675 | | |
| | | 676 | | private static bool TryGetRationalPointSweepDistance( |
| | | 677 | | SweepRationalPoint point, |
| | | 678 | | Vector2d start, |
| | | 679 | | Vector2d direction, |
| | | 680 | | Fixed64 maxDistance, |
| | | 681 | | Fixed64 radius, |
| | | 682 | | out Fixed64 distance) |
| | | 683 | | { |
| | 1497 | 684 | | Signed576 deltaX = WideArithmetic.SubtractSigned576( |
| | 1497 | 685 | | WideArithmetic.MultiplySigned576( |
| | 1497 | 686 | | point.Denominator, |
| | 1497 | 687 | | Signed192.Raw(start.X)), |
| | 1497 | 688 | | point.X); |
| | 1497 | 689 | | Signed576 deltaZ = WideArithmetic.SubtractSigned576( |
| | 1497 | 690 | | WideArithmetic.MultiplySigned576( |
| | 1497 | 691 | | point.Denominator, |
| | 1497 | 692 | | Signed192.Raw(start.Y)), |
| | 1497 | 693 | | point.Z); |
| | 1497 | 694 | | Signed576 directionX = WideArithmetic.MultiplySigned576( |
| | 1497 | 695 | | point.Denominator, |
| | 1497 | 696 | | Signed192.Raw(direction.X)); |
| | 1497 | 697 | | Signed576 directionZ = WideArithmetic.MultiplySigned576( |
| | 1497 | 698 | | point.Denominator, |
| | 1497 | 699 | | Signed192.Raw(direction.Y)); |
| | 1497 | 700 | | Signed576 radiusNumerator = WideArithmetic.MultiplySigned576( |
| | 1497 | 701 | | point.Denominator, |
| | 1497 | 702 | | Signed192.Raw(radius)); |
| | 1497 | 703 | | Signed832 constant = WideArithmetic.SubtractSigned832( |
| | 1497 | 704 | | WideArithmetic.AddSigned832( |
| | 1497 | 705 | | WideArithmetic.MultiplySigned576ToSigned832(deltaX, deltaX), |
| | 1497 | 706 | | WideArithmetic.MultiplySigned576ToSigned832(deltaZ, deltaZ)), |
| | 1497 | 707 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 1497 | 708 | | radiusNumerator, |
| | 1497 | 709 | | radiusNumerator)); |
| | 1497 | 710 | | Signed832 projection = WideArithmetic.AddSigned832( |
| | 1497 | 711 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 1497 | 712 | | deltaX, |
| | 1497 | 713 | | directionX), |
| | 1497 | 714 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 1497 | 715 | | deltaZ, |
| | 1497 | 716 | | directionZ)); |
| | | 717 | | // Triangle-sweep callers share this vertex solver and can reach it |
| | | 718 | | // without a whole-shape start-overlap precheck. |
| | 1497 | 719 | | if (constant.Sign <= 0) |
| | | 720 | | { |
| | 7 | 721 | | distance = Fixed64.Zero; |
| | 7 | 722 | | return true; |
| | | 723 | | } |
| | 1490 | 724 | | if (projection.Sign >= 0) |
| | | 725 | | { |
| | 15 | 726 | | distance = default; |
| | 15 | 727 | | return false; |
| | | 728 | | } |
| | | 729 | | |
| | 1475 | 730 | | Signed832 directionSquared = WideArithmetic.AddSigned832( |
| | 1475 | 731 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 1475 | 732 | | directionX, |
| | 1475 | 733 | | directionX), |
| | 1475 | 734 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 1475 | 735 | | directionZ, |
| | 1475 | 736 | | directionZ)); |
| | 1475 | 737 | | Signed832 negativeProjection = |
| | 1475 | 738 | | WideArithmetic.SubtractSigned832(default, projection); |
| | 1475 | 739 | | bool closestBeyondMaximum = |
| | 1475 | 740 | | WideArithmetic.CompareNonNegativeProducts( |
| | 1475 | 741 | | negativeProjection, |
| | 1475 | 742 | | Signed832.ExtendValue(SweepRawScale), |
| | 1475 | 743 | | directionSquared, |
| | 1475 | 744 | | Signed832.ExtendValue(Signed192.Signed(maxDistance.m_rawValue))) > 0; |
| | 1475 | 745 | | if (closestBeyondMaximum) |
| | | 746 | | { |
| | 46 | 747 | | if (CompareRationalPointAt( |
| | 46 | 748 | | deltaX, |
| | 46 | 749 | | deltaZ, |
| | 46 | 750 | | directionX, |
| | 46 | 751 | | directionZ, |
| | 46 | 752 | | radiusNumerator, |
| | 46 | 753 | | Signed192.Signed(maxDistance.m_rawValue), |
| | 46 | 754 | | SweepRawScale) > 0) |
| | | 755 | | { |
| | 44 | 756 | | distance = default; |
| | 44 | 757 | | return false; |
| | | 758 | | } |
| | | 759 | | } |
| | 1429 | 760 | | else if (WideArithmetic.CompareNonNegativeProducts( |
| | 1429 | 761 | | negativeProjection, |
| | 1429 | 762 | | negativeProjection, |
| | 1429 | 763 | | directionSquared, |
| | 1429 | 764 | | constant) < 0) |
| | | 765 | | { |
| | 1322 | 766 | | distance = default; |
| | 1322 | 767 | | return false; |
| | | 768 | | } |
| | | 769 | | |
| | 109 | 770 | | Fixed64 closest = maxDistance; |
| | 109 | 771 | | if (!closestBeyondMaximum) |
| | | 772 | | { |
| | | 773 | | // The exact comparison above proves this nonnegative quotient is |
| | | 774 | | // no greater than maxDistance, so its final Q32.32 value is |
| | | 775 | | // representable. |
| | 107 | 776 | | _ = Fixed64.TryGetSignedRawRatio( |
| | 107 | 777 | | negativeProjection, |
| | 107 | 778 | | directionSquared, |
| | 107 | 779 | | FixedMath.SHIFT_AMOUNT_I, |
| | 107 | 780 | | out closest); |
| | | 781 | | } |
| | | 782 | | |
| | 109 | 783 | | long maximumSearchRaw = closest.m_rawValue; |
| | 109 | 784 | | long high = Math.Max(0L, maximumSearchRaw - 1L); |
| | 109 | 785 | | if (CompareRationalPointAtHalf( |
| | 109 | 786 | | deltaX, |
| | 109 | 787 | | deltaZ, |
| | 109 | 788 | | directionX, |
| | 109 | 789 | | directionZ, |
| | 109 | 790 | | radiusNumerator, |
| | 109 | 791 | | high) > 0) |
| | | 792 | | { |
| | 5 | 793 | | distance = closestBeyondMaximum ? maxDistance : closest; |
| | 5 | 794 | | return true; |
| | | 795 | | } |
| | | 796 | | |
| | 104 | 797 | | long low = 0L; |
| | 3568 | 798 | | while (low < high) |
| | | 799 | | { |
| | 3464 | 800 | | long middle = low + ((high - low) >> 1); |
| | 3464 | 801 | | if (CompareRationalPointAtHalf( |
| | 3464 | 802 | | deltaX, |
| | 3464 | 803 | | deltaZ, |
| | 3464 | 804 | | directionX, |
| | 3464 | 805 | | directionZ, |
| | 3464 | 806 | | radiusNumerator, |
| | 3464 | 807 | | middle) <= 0) |
| | | 808 | | { |
| | 2721 | 809 | | high = middle; |
| | | 810 | | } |
| | | 811 | | else |
| | | 812 | | { |
| | 743 | 813 | | low = middle + 1L; |
| | | 814 | | } |
| | | 815 | | } |
| | | 816 | | |
| | 104 | 817 | | int midpointComparison = CompareRationalPointAtHalf( |
| | 104 | 818 | | deltaX, |
| | 104 | 819 | | deltaZ, |
| | 104 | 820 | | directionX, |
| | 104 | 821 | | directionZ, |
| | 104 | 822 | | radiusNumerator, |
| | 104 | 823 | | low); |
| | 104 | 824 | | distance = Fixed64.FromRaw( |
| | 104 | 825 | | low + GetHalfToEvenIncrement(midpointComparison, low)); |
| | 104 | 826 | | return true; |
| | | 827 | | } |
| | | 828 | | |
| | | 829 | | private static long GetHalfToEvenIncrement( |
| | | 830 | | int midpointComparison, |
| | | 831 | | long lowerRaw) |
| | | 832 | | { |
| | 755 | 833 | | int nonzero = |
| | 755 | 834 | | (int)((uint)(midpointComparison | -midpointComparison) >> 31); |
| | 755 | 835 | | int zero = nonzero ^ 1; |
| | 755 | 836 | | return zero & (lowerRaw & 1L); |
| | | 837 | | } |
| | | 838 | | |
| | | 839 | | private static int CompareRationalPointAtHalf( |
| | | 840 | | Signed576 deltaX, |
| | | 841 | | Signed576 deltaZ, |
| | | 842 | | Signed576 directionX, |
| | | 843 | | Signed576 directionZ, |
| | | 844 | | Signed576 radiusNumerator, |
| | | 845 | | long lowerRaw) |
| | | 846 | | { |
| | 3677 | 847 | | Signed192 lower = Signed192.Signed(lowerRaw); |
| | 3677 | 848 | | Signed192 midpoint = WideArithmetic.AddSigned192( |
| | 3677 | 849 | | WideArithmetic.AddSigned192(lower, lower), |
| | 3677 | 850 | | SweepOneCoefficient); |
| | 3677 | 851 | | return CompareRationalPointAt( |
| | 3677 | 852 | | deltaX, |
| | 3677 | 853 | | deltaZ, |
| | 3677 | 854 | | directionX, |
| | 3677 | 855 | | directionZ, |
| | 3677 | 856 | | radiusNumerator, |
| | 3677 | 857 | | midpoint, |
| | 3677 | 858 | | SweepDoubleRawScale); |
| | | 859 | | } |
| | | 860 | | |
| | | 861 | | private static int CompareRationalPointAt( |
| | | 862 | | Signed576 deltaX, |
| | | 863 | | Signed576 deltaZ, |
| | | 864 | | Signed576 directionX, |
| | | 865 | | Signed576 directionZ, |
| | | 866 | | Signed576 radiusNumerator, |
| | | 867 | | Signed192 timeNumerator, |
| | | 868 | | Signed192 timeDenominator) |
| | | 869 | | { |
| | 3723 | 870 | | Signed576 x = WideArithmetic.AddSigned576( |
| | 3723 | 871 | | WideArithmetic.MultiplySigned576(deltaX, timeDenominator), |
| | 3723 | 872 | | WideArithmetic.MultiplySigned576(directionX, timeNumerator)); |
| | 3723 | 873 | | Signed576 z = WideArithmetic.AddSigned576( |
| | 3723 | 874 | | WideArithmetic.MultiplySigned576(deltaZ, timeDenominator), |
| | 3723 | 875 | | WideArithmetic.MultiplySigned576(directionZ, timeNumerator)); |
| | 3723 | 876 | | Signed576 scaledRadius = |
| | 3723 | 877 | | WideArithmetic.MultiplySigned576( |
| | 3723 | 878 | | radiusNumerator, |
| | 3723 | 879 | | timeDenominator); |
| | 3723 | 880 | | return WideArithmetic.SubtractSigned832( |
| | 3723 | 881 | | WideArithmetic.AddSigned832( |
| | 3723 | 882 | | WideArithmetic.MultiplySigned576ToSigned832(x, x), |
| | 3723 | 883 | | WideArithmetic.MultiplySigned576ToSigned832(z, z)), |
| | 3723 | 884 | | WideArithmetic.MultiplySigned576ToSigned832( |
| | 3723 | 885 | | scaledRadius, |
| | 3723 | 886 | | scaledRadius)).Sign; |
| | | 887 | | } |
| | | 888 | | |
| | | 889 | | private static Signed576 GetSweepProjection( |
| | | 890 | | SweepPlanarConstraint constraint, |
| | | 891 | | Vector2d point) => |
| | 15506 | 892 | | WideArithmetic.AddSigned576( |
| | 15506 | 893 | | WideArithmetic.MultiplySigned320( |
| | 15506 | 894 | | constraint.A, |
| | 15506 | 895 | | Signed320.ExtendValue(Signed192.Raw(point.X))), |
| | 15506 | 896 | | WideArithmetic.MultiplySigned320( |
| | 15506 | 897 | | constraint.C, |
| | 15506 | 898 | | Signed320.ExtendValue(Signed192.Raw(point.Y)))); |
| | | 899 | | } |