| | | 1 | | //======================================================================= |
| | | 2 | | // WideFiniteAxisProjection.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 | | namespace FixedMathSharp.Geometry; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Provides deterministic, high-precision (wide/Signed192) axis-projection utilities for evaluating |
| | | 12 | | /// separating-axis overlap and penetration depth between finite-length capsule and cylinder shapes. |
| | | 13 | | /// Projects shape extents and centers onto a given axis using extended-precision arithmetic to avoid |
| | | 14 | | /// overflow/rounding issues inherent in fixed-point math, enabling robust SAT-based collision detection |
| | | 15 | | /// and accurate minimum translation vector (MTV) computation for narrow-phase physics queries. |
| | | 16 | | /// </summary> |
| | | 17 | | internal static class WideFiniteAxisProjection |
| | | 18 | | { |
| | 1 | 19 | | private static readonly Signed192 Scale = Signed192.Signed(Fixed64.One.m_rawValue); |
| | 1 | 20 | | private static readonly Signed192 DoubleScale = Signed192.Signed(Fixed64.Two.m_rawValue); |
| | 1 | 21 | | private static readonly Signed192 ScaleSquared = GetScaleSquared(); |
| | | 22 | | |
| | | 23 | | #region Nested Types |
| | | 24 | | |
| | | 25 | | private readonly struct ProjectionDepth |
| | | 26 | | { |
| | | 27 | | internal readonly Signed320 RationalNumerator; |
| | | 28 | | internal readonly Signed192 RationalDenominator; |
| | | 29 | | internal readonly Radical First; |
| | | 30 | | internal readonly Radical Second; |
| | | 31 | | |
| | | 32 | | internal ProjectionDepth( |
| | | 33 | | Signed320 rationalNumerator, |
| | | 34 | | Signed192 rationalDenominator, |
| | | 35 | | Radical first, |
| | | 36 | | Radical second) |
| | | 37 | | { |
| | 377 | 38 | | RationalNumerator = rationalNumerator; |
| | 377 | 39 | | RationalDenominator = rationalDenominator; |
| | 377 | 40 | | First = first; |
| | 377 | 41 | | Second = second; |
| | 377 | 42 | | } |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | private readonly struct Radical |
| | | 46 | | { |
| | | 47 | | internal readonly Signed576 Numerator; |
| | | 48 | | internal readonly Signed192 Denominator; |
| | | 49 | | |
| | | 50 | | internal Radical(Signed576 numerator, Signed192 denominator) |
| | | 51 | | { |
| | 737 | 52 | | Numerator = numerator; |
| | 737 | 53 | | Denominator = denominator; |
| | 737 | 54 | | } |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | #endregion |
| | | 58 | | |
| | | 59 | | internal static bool DoCylinderCapsuleOverlapOnAxis( |
| | | 60 | | Vector3d projectionAxis, |
| | | 61 | | Vector3d cylinderCenter, |
| | | 62 | | Vector3d cylinderAxis, |
| | | 63 | | Fixed64 cylinderLength, |
| | | 64 | | Fixed64 cylinderRadius, |
| | | 65 | | Vector3d capsuleCenter, |
| | | 66 | | Vector3d capsuleAxis, |
| | | 67 | | Fixed64 capsuleLength, |
| | | 68 | | Fixed64 capsuleRadius) |
| | | 69 | | { |
| | 3 | 70 | | CreateCylinderCapsuleDepth( |
| | 3 | 71 | | projectionAxis, |
| | 3 | 72 | | cylinderCenter, |
| | 3 | 73 | | cylinderAxis, |
| | 3 | 74 | | cylinderLength, |
| | 3 | 75 | | cylinderRadius, |
| | 3 | 76 | | capsuleCenter, |
| | 3 | 77 | | capsuleAxis, |
| | 3 | 78 | | capsuleLength, |
| | 3 | 79 | | capsuleRadius, |
| | 3 | 80 | | out ProjectionDepth depth); |
| | 3 | 81 | | return CompareToTwiceRaw(depth, default) >= 0; |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | internal static bool TryGetCylinderCapsuleAxisPenetration( |
| | | 85 | | Vector3d projectionAxis, |
| | | 86 | | Vector3d cylinderCenter, |
| | | 87 | | Vector3d cylinderAxis, |
| | | 88 | | Fixed64 cylinderLength, |
| | | 89 | | Fixed64 cylinderRadius, |
| | | 90 | | Vector3d capsuleCenter, |
| | | 91 | | Vector3d capsuleAxis, |
| | | 92 | | Fixed64 capsuleLength, |
| | | 93 | | Fixed64 capsuleRadius, |
| | | 94 | | out Vector3d orientedAxis, |
| | | 95 | | out Fixed64 penetrationDepth) |
| | | 96 | | { |
| | 7 | 97 | | bool result = TryGetCylinderCapsuleAxisPenetration( |
| | 7 | 98 | | projectionAxis, |
| | 7 | 99 | | cylinderCenter, |
| | 7 | 100 | | cylinderAxis, |
| | 7 | 101 | | cylinderLength, |
| | 7 | 102 | | cylinderRadius, |
| | 7 | 103 | | capsuleCenter, |
| | 7 | 104 | | capsuleAxis, |
| | 7 | 105 | | capsuleLength, |
| | 7 | 106 | | capsuleRadius, |
| | 7 | 107 | | out orientedAxis, |
| | 7 | 108 | | out penetrationDepth, |
| | 7 | 109 | | out bool depthIsClamped); |
| | 7 | 110 | | return result & !depthIsClamped; |
| | | 111 | | } |
| | | 112 | | |
| | | 113 | | internal static bool TryGetCylinderCapsuleAxisPenetration( |
| | | 114 | | Vector3d projectionAxis, |
| | | 115 | | Vector3d cylinderCenter, |
| | | 116 | | Vector3d cylinderAxis, |
| | | 117 | | Fixed64 cylinderLength, |
| | | 118 | | Fixed64 cylinderRadius, |
| | | 119 | | Vector3d capsuleCenter, |
| | | 120 | | Vector3d capsuleAxis, |
| | | 121 | | Fixed64 capsuleLength, |
| | | 122 | | Fixed64 capsuleRadius, |
| | | 123 | | out Vector3d orientedAxis, |
| | | 124 | | out Fixed64 penetrationDepth, |
| | | 125 | | out bool depthIsClamped) |
| | | 126 | | { |
| | 13 | 127 | | CreateCylinderCapsuleDepth( |
| | 13 | 128 | | projectionAxis, |
| | 13 | 129 | | cylinderCenter, |
| | 13 | 130 | | cylinderAxis, |
| | 13 | 131 | | cylinderLength, |
| | 13 | 132 | | cylinderRadius, |
| | 13 | 133 | | capsuleCenter, |
| | 13 | 134 | | capsuleAxis, |
| | 13 | 135 | | capsuleLength, |
| | 13 | 136 | | capsuleRadius, |
| | 13 | 137 | | out ProjectionDepth depth); |
| | 13 | 138 | | return TryMaterializeDepth( |
| | 13 | 139 | | depth, |
| | 13 | 140 | | projectionAxis, |
| | 13 | 141 | | GetDot(capsuleCenter, cylinderCenter, projectionAxis), |
| | 13 | 142 | | out orientedAxis, |
| | 13 | 143 | | out penetrationDepth, |
| | 13 | 144 | | out depthIsClamped); |
| | | 145 | | } |
| | | 146 | | |
| | | 147 | | internal static bool DoCylindersOverlapOnAxis( |
| | | 148 | | Vector3d projectionAxis, |
| | | 149 | | Vector3d firstCenter, |
| | | 150 | | Vector3d firstAxis, |
| | | 151 | | Fixed64 firstLength, |
| | | 152 | | Fixed64 firstRadius, |
| | | 153 | | Vector3d secondCenter, |
| | | 154 | | Vector3d secondAxis, |
| | | 155 | | Fixed64 secondLength, |
| | | 156 | | Fixed64 secondRadius) |
| | | 157 | | { |
| | 217 | 158 | | CreateCylinderDepth( |
| | 217 | 159 | | projectionAxis, |
| | 217 | 160 | | firstCenter, |
| | 217 | 161 | | firstAxis, |
| | 217 | 162 | | firstLength, |
| | 217 | 163 | | firstRadius, |
| | 217 | 164 | | secondCenter, |
| | 217 | 165 | | secondAxis, |
| | 217 | 166 | | secondLength, |
| | 217 | 167 | | secondRadius, |
| | 217 | 168 | | out ProjectionDepth depth); |
| | 217 | 169 | | return CompareToTwiceRaw(depth, default) >= 0; |
| | | 170 | | } |
| | | 171 | | |
| | | 172 | | internal static bool TryGetCylindersAxisPenetration( |
| | | 173 | | Vector3d projectionAxis, |
| | | 174 | | Vector3d firstCenter, |
| | | 175 | | Vector3d firstAxis, |
| | | 176 | | Fixed64 firstLength, |
| | | 177 | | Fixed64 firstRadius, |
| | | 178 | | Vector3d secondCenter, |
| | | 179 | | Vector3d secondAxis, |
| | | 180 | | Fixed64 secondLength, |
| | | 181 | | Fixed64 secondRadius, |
| | | 182 | | out Vector3d orientedAxis, |
| | | 183 | | out Fixed64 penetrationDepth) |
| | | 184 | | { |
| | 116 | 185 | | bool result = TryGetCylindersAxisPenetration( |
| | 116 | 186 | | projectionAxis, |
| | 116 | 187 | | firstCenter, |
| | 116 | 188 | | firstAxis, |
| | 116 | 189 | | firstLength, |
| | 116 | 190 | | firstRadius, |
| | 116 | 191 | | secondCenter, |
| | 116 | 192 | | secondAxis, |
| | 116 | 193 | | secondLength, |
| | 116 | 194 | | secondRadius, |
| | 116 | 195 | | out orientedAxis, |
| | 116 | 196 | | out penetrationDepth, |
| | 116 | 197 | | out bool depthIsClamped); |
| | 116 | 198 | | return result && !depthIsClamped; |
| | | 199 | | } |
| | | 200 | | |
| | | 201 | | internal static bool TryGetCylindersAxisPenetration( |
| | | 202 | | Vector3d projectionAxis, |
| | | 203 | | Vector3d firstCenter, |
| | | 204 | | Vector3d firstAxis, |
| | | 205 | | Fixed64 firstLength, |
| | | 206 | | Fixed64 firstRadius, |
| | | 207 | | Vector3d secondCenter, |
| | | 208 | | Vector3d secondAxis, |
| | | 209 | | Fixed64 secondLength, |
| | | 210 | | Fixed64 secondRadius, |
| | | 211 | | out Vector3d orientedAxis, |
| | | 212 | | out Fixed64 penetrationDepth, |
| | | 213 | | out bool depthIsClamped) |
| | | 214 | | { |
| | 117 | 215 | | CreateCylinderDepth( |
| | 117 | 216 | | projectionAxis, |
| | 117 | 217 | | firstCenter, |
| | 117 | 218 | | firstAxis, |
| | 117 | 219 | | firstLength, |
| | 117 | 220 | | firstRadius, |
| | 117 | 221 | | secondCenter, |
| | 117 | 222 | | secondAxis, |
| | 117 | 223 | | secondLength, |
| | 117 | 224 | | secondRadius, |
| | 117 | 225 | | out ProjectionDepth depth); |
| | 117 | 226 | | return TryMaterializeDepth( |
| | 117 | 227 | | depth, |
| | 117 | 228 | | projectionAxis, |
| | 117 | 229 | | GetDot(secondCenter, firstCenter, projectionAxis), |
| | 117 | 230 | | out orientedAxis, |
| | 117 | 231 | | out penetrationDepth, |
| | 117 | 232 | | out depthIsClamped); |
| | | 233 | | } |
| | | 234 | | |
| | | 235 | | private static void CreateCylinderCapsuleDepth( |
| | | 236 | | Vector3d projectionAxis, |
| | | 237 | | Vector3d cylinderCenter, |
| | | 238 | | Vector3d cylinderAxis, |
| | | 239 | | Fixed64 cylinderLength, |
| | | 240 | | Fixed64 cylinderRadius, |
| | | 241 | | Vector3d capsuleCenter, |
| | | 242 | | Vector3d capsuleAxis, |
| | | 243 | | Fixed64 capsuleLength, |
| | | 244 | | Fixed64 capsuleRadius, |
| | | 245 | | out ProjectionDepth depth) |
| | | 246 | | { |
| | 16 | 247 | | CreateRationalDepth( |
| | 16 | 248 | | projectionAxis, |
| | 16 | 249 | | cylinderCenter, |
| | 16 | 250 | | cylinderAxis, |
| | 16 | 251 | | cylinderLength, |
| | 16 | 252 | | capsuleCenter, |
| | 16 | 253 | | capsuleAxis, |
| | 16 | 254 | | capsuleLength, |
| | 16 | 255 | | out Signed320 rationalNumerator, |
| | 16 | 256 | | out Signed192 rationalDenominator); |
| | 16 | 257 | | depth = new ProjectionDepth( |
| | 16 | 258 | | rationalNumerator, |
| | 16 | 259 | | rationalDenominator, |
| | 16 | 260 | | CreateCylinderRadical(projectionAxis, cylinderAxis, cylinderRadius), |
| | 16 | 261 | | CreateCapsuleRadical(projectionAxis, capsuleRadius)); |
| | 16 | 262 | | } |
| | | 263 | | |
| | | 264 | | private static void CreateCylinderDepth( |
| | | 265 | | Vector3d projectionAxis, |
| | | 266 | | Vector3d firstCenter, |
| | | 267 | | Vector3d firstAxis, |
| | | 268 | | Fixed64 firstLength, |
| | | 269 | | Fixed64 firstRadius, |
| | | 270 | | Vector3d secondCenter, |
| | | 271 | | Vector3d secondAxis, |
| | | 272 | | Fixed64 secondLength, |
| | | 273 | | Fixed64 secondRadius, |
| | | 274 | | out ProjectionDepth depth) |
| | | 275 | | { |
| | 334 | 276 | | CreateRationalDepth( |
| | 334 | 277 | | projectionAxis, |
| | 334 | 278 | | firstCenter, |
| | 334 | 279 | | firstAxis, |
| | 334 | 280 | | firstLength, |
| | 334 | 281 | | secondCenter, |
| | 334 | 282 | | secondAxis, |
| | 334 | 283 | | secondLength, |
| | 334 | 284 | | out Signed320 rationalNumerator, |
| | 334 | 285 | | out Signed192 rationalDenominator); |
| | 334 | 286 | | depth = new ProjectionDepth( |
| | 334 | 287 | | rationalNumerator, |
| | 334 | 288 | | rationalDenominator, |
| | 334 | 289 | | CreateCylinderRadical(projectionAxis, firstAxis, firstRadius), |
| | 334 | 290 | | CreateCylinderRadical(projectionAxis, secondAxis, secondRadius)); |
| | 334 | 291 | | } |
| | | 292 | | |
| | | 293 | | private static void CreateRationalDepth( |
| | | 294 | | Vector3d projectionAxis, |
| | | 295 | | Vector3d firstCenter, |
| | | 296 | | Vector3d firstAxis, |
| | | 297 | | Fixed64 firstLength, |
| | | 298 | | Vector3d secondCenter, |
| | | 299 | | Vector3d secondAxis, |
| | | 300 | | Fixed64 secondLength, |
| | | 301 | | out Signed320 numerator, |
| | | 302 | | out Signed192 denominator) |
| | | 303 | | { |
| | 350 | 304 | | Signed192 firstAlignment = WideArithmetic.Absolute(GetDot(firstAxis, projectionAxis)); |
| | 350 | 305 | | Signed192 secondAlignment = WideArithmetic.Absolute(GetDot(secondAxis, projectionAxis)); |
| | 350 | 306 | | Signed192 centerSeparation = WideArithmetic.Absolute( |
| | 350 | 307 | | GetDot(secondCenter, firstCenter, projectionAxis)); |
| | 350 | 308 | | numerator = WideArithmetic.SubtractSigned320( |
| | 350 | 309 | | WideArithmetic.AddSigned320( |
| | 350 | 310 | | WideArithmetic.MultiplySigned192( |
| | 350 | 311 | | firstAlignment, |
| | 350 | 312 | | Signed192.Signed(firstLength.m_rawValue)), |
| | 350 | 313 | | WideArithmetic.MultiplySigned192( |
| | 350 | 314 | | secondAlignment, |
| | 350 | 315 | | Signed192.Signed(secondLength.m_rawValue))), |
| | 350 | 316 | | WideArithmetic.MultiplySigned192(centerSeparation, DoubleScale)); |
| | 350 | 317 | | Signed320 wideDenominator = WideArithmetic.MultiplySigned192( |
| | 350 | 318 | | DoubleScale, |
| | 350 | 319 | | Scale); |
| | 350 | 320 | | denominator = new Signed192( |
| | 350 | 321 | | wideDenominator.Word2, |
| | 350 | 322 | | wideDenominator.Word1, |
| | 350 | 323 | | wideDenominator.Word0); |
| | 350 | 324 | | } |
| | | 325 | | |
| | | 326 | | private static Radical CreateCylinderRadical( |
| | | 327 | | Vector3d projectionAxis, |
| | | 328 | | Vector3d cylinderAxis, |
| | | 329 | | Fixed64 radius) |
| | | 330 | | { |
| | 714 | 331 | | Signed192 axisSquared = GetDot(cylinderAxis, cylinderAxis); |
| | 714 | 332 | | Signed192 projectionSquared = GetDot(projectionAxis, projectionAxis); |
| | 714 | 333 | | Signed192 alignment = GetDot(cylinderAxis, projectionAxis); |
| | 714 | 334 | | Signed320 planeSquared = WideArithmetic.MultiplySubtract( |
| | 714 | 335 | | axisSquared, |
| | 714 | 336 | | projectionSquared, |
| | 714 | 337 | | alignment, |
| | 714 | 338 | | alignment); |
| | 714 | 339 | | Signed320 radiusSquared = WideArithmetic.MultiplySigned192( |
| | 714 | 340 | | Signed192.Signed(radius.m_rawValue), |
| | 714 | 341 | | Signed192.Signed(radius.m_rawValue)); |
| | 714 | 342 | | Signed576 numerator = WideArithmetic.MultiplySigned320( |
| | 714 | 343 | | radiusSquared, |
| | 714 | 344 | | planeSquared); |
| | 714 | 345 | | Signed576 wideDenominator = WideArithmetic.MultiplySigned576( |
| | 714 | 346 | | Signed576.ExtendValue( |
| | 714 | 347 | | WideArithmetic.MultiplySigned192(axisSquared, ScaleSquared)), |
| | 714 | 348 | | Signed192.Signed(1L)); |
| | | 349 | | // A normalized direction squared is Q64-scaled; multiplying by the |
| | | 350 | | // Q64 scale denominator needs at most 129 signed bits. |
| | 714 | 351 | | Signed192 denominator = new( |
| | 714 | 352 | | wideDenominator.Word2, |
| | 714 | 353 | | wideDenominator.Word1, |
| | 714 | 354 | | wideDenominator.Word0); |
| | 714 | 355 | | return new Radical(numerator, denominator); |
| | | 356 | | } |
| | | 357 | | |
| | | 358 | | private static Radical CreateCapsuleRadical( |
| | | 359 | | Vector3d projectionAxis, |
| | | 360 | | Fixed64 radius) |
| | | 361 | | { |
| | 20 | 362 | | Signed320 radiusSquared = WideArithmetic.MultiplySigned192( |
| | 20 | 363 | | Signed192.Signed(radius.m_rawValue), |
| | 20 | 364 | | Signed192.Signed(radius.m_rawValue)); |
| | 20 | 365 | | Signed192 projectionSquared = GetDot(projectionAxis, projectionAxis); |
| | 20 | 366 | | Signed576 numerator = WideArithmetic.MultiplySigned576( |
| | 20 | 367 | | Signed576.ExtendValue(radiusSquared), |
| | 20 | 368 | | projectionSquared); |
| | 20 | 369 | | return new Radical(numerator, ScaleSquared); |
| | | 370 | | } |
| | | 371 | | |
| | | 372 | | private static bool TryMaterializeDepth( |
| | | 373 | | ProjectionDepth depth, |
| | | 374 | | Vector3d projectionAxis, |
| | | 375 | | Signed192 centerProjection, |
| | | 376 | | out Vector3d orientedAxis, |
| | | 377 | | out Fixed64 result, |
| | | 378 | | out bool depthIsClamped) |
| | | 379 | | { |
| | 137 | 380 | | return TryMaterializeDepth( |
| | 137 | 381 | | depth, |
| | 137 | 382 | | centerProjection.Sign < 0 |
| | 137 | 383 | | ? -projectionAxis |
| | 137 | 384 | | : projectionAxis, |
| | 137 | 385 | | out orientedAxis, |
| | 137 | 386 | | out result, |
| | 137 | 387 | | out depthIsClamped); |
| | | 388 | | } |
| | | 389 | | |
| | | 390 | | private static bool TryMaterializeDepth( |
| | | 391 | | ProjectionDepth depth, |
| | | 392 | | Vector3d selectedAxis, |
| | | 393 | | out Vector3d orientedAxis, |
| | | 394 | | out Fixed64 result, |
| | | 395 | | out bool depthIsClamped) |
| | | 396 | | { |
| | 145 | 397 | | if (CompareToTwiceRaw(depth, default) < 0) |
| | | 398 | | { |
| | 25 | 399 | | orientedAxis = default; |
| | 25 | 400 | | result = default; |
| | 25 | 401 | | depthIsClamped = default; |
| | 25 | 402 | | return false; |
| | | 403 | | } |
| | | 404 | | |
| | 120 | 405 | | orientedAxis = selectedAxis; |
| | 120 | 406 | | if (CompareToTwiceRaw( |
| | 120 | 407 | | depth, |
| | 120 | 408 | | new Signed192(0UL, 0UL, ulong.MaxValue - 1UL)) > 0) |
| | | 409 | | { |
| | 7 | 410 | | result = Fixed64.MaxValue; |
| | 7 | 411 | | depthIsClamped = true; |
| | 7 | 412 | | return true; |
| | | 413 | | } |
| | | 414 | | |
| | 113 | 415 | | bool approximationsAreRepresentable = |
| | 113 | 416 | | TryGetRadicalApproximation(depth.First, out Fixed64 firstApproximation) |
| | 113 | 417 | | & TryGetRadicalApproximation(depth.Second, out Fixed64 secondApproximation); |
| | 113 | 418 | | if (!approximationsAreRepresentable) |
| | | 419 | | { |
| | | 420 | | // Individual supports may exceed Fixed64 even when their sum |
| | | 421 | | // cancels against the rational separation into range. |
| | 3 | 422 | | result = GetRoundedDepthByExactSearch(depth); |
| | 3 | 423 | | depthIsClamped = false; |
| | 3 | 424 | | return true; |
| | | 425 | | } |
| | | 426 | | |
| | 110 | 427 | | Signed192 approximatedRadicals = WideArithmetic.AddSigned192( |
| | 110 | 428 | | Signed192.Signed(firstApproximation.m_rawValue), |
| | 110 | 429 | | Signed192.Signed(secondApproximation.m_rawValue)); |
| | 110 | 430 | | Signed320 approximationNumerator = WideArithmetic.AddSigned320( |
| | 110 | 431 | | depth.RationalNumerator, |
| | 110 | 432 | | WideArithmetic.MultiplySigned192( |
| | 110 | 433 | | depth.RationalDenominator, |
| | 110 | 434 | | approximatedRadicals)); |
| | | 435 | | // Cancel the rational and radical terms before narrowing. The |
| | | 436 | | // nonnegative floor gives correction a bounded endpoint even when an |
| | | 437 | | // individual term is outside the Fixed64 domain. |
| | 110 | 438 | | result = Fixed64.GetNonNegativeRawRatioFloor( |
| | 110 | 439 | | Signed704.ExtendValue( |
| | 110 | 440 | | Signed576.ExtendValue(approximationNumerator)), |
| | 110 | 441 | | Signed704.ExtendValue( |
| | 110 | 442 | | Signed576.ExtendValue( |
| | 110 | 443 | | Signed320.ExtendValue( |
| | 110 | 444 | | depth.RationalDenominator)))); |
| | | 445 | | |
| | 110 | 446 | | CorrectRoundedDepth(depth, ref result); |
| | 110 | 447 | | depthIsClamped = false; |
| | 110 | 448 | | return true; |
| | | 449 | | } |
| | | 450 | | |
| | | 451 | | private static bool TryGetRadicalApproximation( |
| | | 452 | | Radical radical, |
| | | 453 | | out Fixed64 result) |
| | | 454 | | { |
| | 226 | 455 | | if (radical.Numerator.IsZero) |
| | | 456 | | { |
| | 71 | 457 | | result = Fixed64.Zero; |
| | 71 | 458 | | return true; |
| | | 459 | | } |
| | | 460 | | |
| | 155 | 461 | | Signed576 root = WideArithmetic.GetFloorSquareRootOfProduct( |
| | 155 | 462 | | Signed832.ExtendValue(radical.Numerator), |
| | 155 | 463 | | radical.Denominator); |
| | 155 | 464 | | return Fixed64.TryGetSignedRawRatio( |
| | 155 | 465 | | root, |
| | 155 | 466 | | Signed576.ExtendValue( |
| | 155 | 467 | | Signed320.ExtendValue(radical.Denominator)), |
| | 155 | 468 | | out result); |
| | | 469 | | } |
| | | 470 | | |
| | | 471 | | private static Fixed64 GetRoundedDepthByExactSearch(ProjectionDepth depth) |
| | | 472 | | { |
| | 3 | 473 | | ulong low = 0UL; |
| | 3 | 474 | | ulong high = (ulong)long.MaxValue; |
| | 3 | 475 | | ulong floor = 0UL; |
| | 192 | 476 | | while (low <= high) |
| | | 477 | | { |
| | 189 | 478 | | ulong midpoint = low + ((high - low) >> 1); |
| | 189 | 479 | | if (CompareToTwiceRaw( |
| | 189 | 480 | | depth, |
| | 189 | 481 | | new Signed192(0UL, 0UL, midpoint << 1)) >= 0) |
| | | 482 | | { |
| | 9 | 483 | | floor = midpoint; |
| | 9 | 484 | | low = midpoint + 1UL; |
| | | 485 | | } |
| | | 486 | | else |
| | | 487 | | { |
| | 180 | 488 | | high = midpoint - 1UL; |
| | | 489 | | } |
| | | 490 | | } |
| | | 491 | | |
| | 3 | 492 | | Fixed64 result = Fixed64.FromRaw((long)floor); |
| | 3 | 493 | | CorrectRoundedDepth(depth, ref result); |
| | 3 | 494 | | return result; |
| | | 495 | | } |
| | | 496 | | |
| | | 497 | | private static void CorrectRoundedDepth( |
| | | 498 | | ProjectionDepth depth, |
| | | 499 | | ref Fixed64 result) |
| | | 500 | | { |
| | 238 | 501 | | for (int iteration = 0; (iteration < 3) & (result > Fixed64.Zero); iteration++) |
| | | 502 | | { |
| | 116 | 503 | | Signed192 lowerMidpoint = new( |
| | 116 | 504 | | 0UL, |
| | 116 | 505 | | unchecked((ulong)result.m_rawValue) >> 63, |
| | 116 | 506 | | unchecked((ulong)(result.m_rawValue + result.m_rawValue - 1L))); |
| | 116 | 507 | | int comparison = CompareToTwiceRaw(depth, lowerMidpoint); |
| | 116 | 508 | | if (comparison >= (result.m_rawValue & 1L)) |
| | | 509 | | { |
| | | 510 | | break; |
| | | 511 | | } |
| | | 512 | | |
| | 6 | 513 | | result = Fixed64.FromRaw(result.m_rawValue - 1L); |
| | | 514 | | } |
| | | 515 | | |
| | 256 | 516 | | for (int iteration = 0; (iteration < 3) & (result < Fixed64.MaxValue); iteration++) |
| | | 517 | | { |
| | 125 | 518 | | Signed192 upperMidpoint = new( |
| | 125 | 519 | | 0UL, |
| | 125 | 520 | | 0UL, |
| | 125 | 521 | | unchecked((ulong)result.m_rawValue << 1) | 1UL); |
| | 125 | 522 | | int comparison = CompareToTwiceRaw(depth, upperMidpoint); |
| | 125 | 523 | | if (comparison + (result.m_rawValue & 1L) <= 0) |
| | | 524 | | { |
| | | 525 | | break; |
| | | 526 | | } |
| | | 527 | | |
| | 15 | 528 | | result = Fixed64.FromRaw(result.m_rawValue + 1L); |
| | | 529 | | } |
| | 113 | 530 | | } |
| | | 531 | | |
| | | 532 | | private static int CompareToTwiceRaw( |
| | | 533 | | ProjectionDepth depth, |
| | | 534 | | Signed192 twiceRaw) |
| | | 535 | | { |
| | 934 | 536 | | Signed320 thresholdNumerator = WideArithmetic.SubtractSigned320( |
| | 934 | 537 | | WideArithmetic.MultiplySigned192( |
| | 934 | 538 | | twiceRaw, |
| | 934 | 539 | | depth.RationalDenominator), |
| | 934 | 540 | | WideArithmetic.AddSigned320( |
| | 934 | 541 | | depth.RationalNumerator, |
| | 934 | 542 | | depth.RationalNumerator)); |
| | 934 | 543 | | if (thresholdNumerator.Sign <= 0) |
| | | 544 | | { |
| | 219 | 545 | | if (thresholdNumerator.Sign < 0) |
| | 195 | 546 | | return 1; |
| | 24 | 547 | | return depth.First.Numerator.IsZero && depth.Second.Numerator.IsZero |
| | 24 | 548 | | ? 0 |
| | 24 | 549 | | : 1; |
| | | 550 | | } |
| | | 551 | | |
| | 715 | 552 | | Signed192 thresholdDenominator = WideArithmetic.AddSigned192( |
| | 715 | 553 | | depth.RationalDenominator, |
| | 715 | 554 | | depth.RationalDenominator); |
| | 715 | 555 | | return WideArithmetic.CompareNonNegativeRadicalSumToRatio( |
| | 715 | 556 | | depth.First.Numerator, |
| | 715 | 557 | | depth.First.Denominator, |
| | 715 | 558 | | depth.Second.Numerator, |
| | 715 | 559 | | depth.Second.Denominator, |
| | 715 | 560 | | thresholdNumerator, |
| | 715 | 561 | | thresholdDenominator); |
| | | 562 | | } |
| | | 563 | | |
| | | 564 | | private static Signed192 GetDot(Vector3d left, Vector3d right) => |
| | 2913 | 565 | | WideGeometry.GetDifferenceDotProduct3D( |
| | 2913 | 566 | | left.X, |
| | 2913 | 567 | | Fixed64.Zero, |
| | 2913 | 568 | | left.Y, |
| | 2913 | 569 | | Fixed64.Zero, |
| | 2913 | 570 | | left.Z, |
| | 2913 | 571 | | Fixed64.Zero, |
| | 2913 | 572 | | right.X, |
| | 2913 | 573 | | Fixed64.Zero, |
| | 2913 | 574 | | right.Y, |
| | 2913 | 575 | | Fixed64.Zero, |
| | 2913 | 576 | | right.Z, |
| | 2913 | 577 | | Fixed64.Zero); |
| | | 578 | | |
| | | 579 | | private static Signed192 GetDot( |
| | | 580 | | Vector3d end, |
| | | 581 | | Vector3d start, |
| | | 582 | | Vector3d direction) => |
| | 504 | 583 | | WideGeometry.GetDifferenceDotProduct3D( |
| | 504 | 584 | | end.X, |
| | 504 | 585 | | start.X, |
| | 504 | 586 | | end.Y, |
| | 504 | 587 | | start.Y, |
| | 504 | 588 | | end.Z, |
| | 504 | 589 | | start.Z, |
| | 504 | 590 | | direction.X, |
| | 504 | 591 | | Fixed64.Zero, |
| | 504 | 592 | | direction.Y, |
| | 504 | 593 | | Fixed64.Zero, |
| | 504 | 594 | | direction.Z, |
| | 504 | 595 | | Fixed64.Zero); |
| | | 596 | | |
| | | 597 | | private static Signed192 GetScaleSquared() |
| | | 598 | | { |
| | 1 | 599 | | Signed320 value = WideArithmetic.MultiplySigned192(Scale, Scale); |
| | 1 | 600 | | return new Signed192(value.Word2, value.Word1, value.Word0); |
| | | 601 | | } |
| | | 602 | | |
| | | 603 | | internal static bool TryGetCapsuleCapsuleSlabAxisPenetration( |
| | | 604 | | Vector3d projectionAxis, |
| | | 605 | | Vector3d capsuleCenter, |
| | | 606 | | Vector3d capsuleAxis, |
| | | 607 | | Fixed64 capsuleLength, |
| | | 608 | | Fixed64 capsuleRadius, |
| | | 609 | | Vector3d slabCenter, |
| | | 610 | | Vector2d slabCapsuleAxis, |
| | | 611 | | Fixed64 slabCapsuleLength, |
| | | 612 | | Fixed64 slabCapsuleRadius, |
| | | 613 | | Fixed64 slabHalfThickness, |
| | | 614 | | out Vector3d orientedAxis, |
| | | 615 | | out Fixed64 depth, |
| | | 616 | | out bool depthIsClamped) |
| | | 617 | | { |
| | 4 | 618 | | CreateSymmetricCapsuleSlabDepth( |
| | 4 | 619 | | projectionAxis, |
| | 4 | 620 | | capsuleCenter, |
| | 4 | 621 | | capsuleAxis, |
| | 4 | 622 | | capsuleLength, |
| | 4 | 623 | | capsuleRadius, |
| | 4 | 624 | | shapeUsesSphericalRadius: true, |
| | 4 | 625 | | slabCenter, |
| | 4 | 626 | | slabCapsuleAxis, |
| | 4 | 627 | | slabCapsuleLength, |
| | 4 | 628 | | slabCapsuleRadius, |
| | 4 | 629 | | slabHalfThickness, |
| | 4 | 630 | | out ProjectionDepth projectionDepth); |
| | 4 | 631 | | return TryMaterializeDepth( |
| | 4 | 632 | | projectionDepth, |
| | 4 | 633 | | projectionAxis, |
| | 4 | 634 | | GetDot(slabCenter, capsuleCenter, projectionAxis), |
| | 4 | 635 | | out orientedAxis, |
| | 4 | 636 | | out depth, |
| | 4 | 637 | | out depthIsClamped); |
| | | 638 | | } |
| | | 639 | | |
| | | 640 | | internal static bool TryGetCylinderCapsuleSlabAxisPenetration( |
| | | 641 | | Vector3d projectionAxis, |
| | | 642 | | Vector3d cylinderCenter, |
| | | 643 | | Vector3d cylinderAxis, |
| | | 644 | | Fixed64 cylinderLength, |
| | | 645 | | Fixed64 cylinderRadius, |
| | | 646 | | Vector3d slabCenter, |
| | | 647 | | Vector2d slabCapsuleAxis, |
| | | 648 | | Fixed64 slabCapsuleLength, |
| | | 649 | | Fixed64 slabCapsuleRadius, |
| | | 650 | | Fixed64 slabHalfThickness, |
| | | 651 | | out Vector3d orientedAxis, |
| | | 652 | | out Fixed64 depth, |
| | | 653 | | out bool depthIsClamped) |
| | | 654 | | { |
| | 3 | 655 | | CreateSymmetricCapsuleSlabDepth( |
| | 3 | 656 | | projectionAxis, |
| | 3 | 657 | | cylinderCenter, |
| | 3 | 658 | | cylinderAxis, |
| | 3 | 659 | | cylinderLength, |
| | 3 | 660 | | cylinderRadius, |
| | 3 | 661 | | shapeUsesSphericalRadius: false, |
| | 3 | 662 | | slabCenter, |
| | 3 | 663 | | slabCapsuleAxis, |
| | 3 | 664 | | slabCapsuleLength, |
| | 3 | 665 | | slabCapsuleRadius, |
| | 3 | 666 | | slabHalfThickness, |
| | 3 | 667 | | out ProjectionDepth projectionDepth); |
| | 3 | 668 | | return TryMaterializeDepth( |
| | 3 | 669 | | projectionDepth, |
| | 3 | 670 | | projectionAxis, |
| | 3 | 671 | | GetDot(slabCenter, cylinderCenter, projectionAxis), |
| | 3 | 672 | | out orientedAxis, |
| | 3 | 673 | | out depth, |
| | 3 | 674 | | out depthIsClamped); |
| | | 675 | | } |
| | | 676 | | |
| | | 677 | | internal static bool TryGetConeCapsuleSlabAxisPenetration( |
| | | 678 | | Vector3d projectionAxis, |
| | | 679 | | Vector3d coneCenter, |
| | | 680 | | Vector3d coneAxis, |
| | | 681 | | Fixed64 coneHeight, |
| | | 682 | | Fixed64 coneRadius, |
| | | 683 | | Vector3d slabCenter, |
| | | 684 | | Vector2d slabCapsuleAxis, |
| | | 685 | | Fixed64 slabCapsuleLength, |
| | | 686 | | Fixed64 slabCapsuleRadius, |
| | | 687 | | Fixed64 slabHalfThickness, |
| | | 688 | | out Vector3d orientedAxis, |
| | | 689 | | out Fixed64 depth, |
| | | 690 | | out bool depthIsClamped) |
| | | 691 | | { |
| | 10 | 692 | | Signed192 centerProjection = |
| | 10 | 693 | | GetDot(slabCenter, coneCenter, projectionAxis); |
| | 10 | 694 | | Signed192 coneAlignment = GetDot(coneAxis, projectionAxis); |
| | 10 | 695 | | Signed320 coneAxial = WideArithmetic.MultiplySigned192( |
| | 10 | 696 | | coneAlignment, |
| | 10 | 697 | | Signed192.Signed(coneHeight.m_rawValue)); |
| | 10 | 698 | | Radical coneDisk = |
| | 10 | 699 | | CreateCylinderRadical(projectionAxis, coneAxis, coneRadius); |
| | 10 | 700 | | Radical slabRadial = |
| | 10 | 701 | | CreateCapsuleSlabRadical(projectionAxis, slabCapsuleRadius); |
| | 10 | 702 | | Signed320 slabRational = CreateCapsuleSlabRational( |
| | 10 | 703 | | projectionAxis, |
| | 10 | 704 | | slabCapsuleAxis, |
| | 10 | 705 | | slabCapsuleLength, |
| | 10 | 706 | | slabHalfThickness); |
| | 10 | 707 | | Signed320 centerRational = WideArithmetic.MultiplySigned192( |
| | 10 | 708 | | centerProjection, |
| | 10 | 709 | | DoubleScale); |
| | 10 | 710 | | Signed192 denominator = GetRationalDenominator(); |
| | | 711 | | |
| | 10 | 712 | | bool maximumUsesBase = coneAxial.Sign <= 0 |
| | 10 | 713 | | || IsRadicalAtLeastRatio(coneDisk, coneAxial); |
| | 10 | 714 | | Signed320 negativeConeAxial = |
| | 10 | 715 | | WideArithmetic.SubtractSigned320(default, coneAxial); |
| | 10 | 716 | | bool minimumUsesBase = negativeConeAxial.Sign <= 0 |
| | 10 | 717 | | || IsRadicalAtLeastRatio(coneDisk, negativeConeAxial); |
| | 10 | 718 | | Signed320 maximumRational = maximumUsesBase |
| | 10 | 719 | | ? negativeConeAxial |
| | 10 | 720 | | : coneAxial; |
| | 10 | 721 | | Signed320 minimumRational = minimumUsesBase |
| | 10 | 722 | | ? negativeConeAxial |
| | 10 | 723 | | : coneAxial; |
| | | 724 | | |
| | 10 | 725 | | var positive = new ProjectionDepth( |
| | 10 | 726 | | WideArithmetic.AddSigned320( |
| | 10 | 727 | | WideArithmetic.SubtractSigned320( |
| | 10 | 728 | | maximumRational, |
| | 10 | 729 | | centerRational), |
| | 10 | 730 | | slabRational), |
| | 10 | 731 | | denominator, |
| | 10 | 732 | | maximumUsesBase ? coneDisk : CreateZeroRadical(), |
| | 10 | 733 | | slabRadial); |
| | 10 | 734 | | var negative = new ProjectionDepth( |
| | 10 | 735 | | WideArithmetic.SubtractSigned320( |
| | 10 | 736 | | WideArithmetic.AddSigned320( |
| | 10 | 737 | | centerRational, |
| | 10 | 738 | | slabRational), |
| | 10 | 739 | | minimumRational), |
| | 10 | 740 | | denominator, |
| | 10 | 741 | | minimumUsesBase ? coneDisk : CreateZeroRadical(), |
| | 10 | 742 | | slabRadial); |
| | 10 | 743 | | if (CompareToTwiceRaw(positive, default) < 0 |
| | 10 | 744 | | || CompareToTwiceRaw(negative, default) < 0) |
| | | 745 | | { |
| | 2 | 746 | | orientedAxis = default; |
| | 2 | 747 | | depth = default; |
| | 2 | 748 | | depthIsClamped = default; |
| | 2 | 749 | | return false; |
| | | 750 | | } |
| | | 751 | | |
| | 8 | 752 | | bool positiveSelected = |
| | 8 | 753 | | CompareProjectionDepthsWithoutSharedSecond( |
| | 8 | 754 | | positive, |
| | 8 | 755 | | negative) <= 0; |
| | 8 | 756 | | ProjectionDepth selected = |
| | 8 | 757 | | positiveSelected ? positive : negative; |
| | 8 | 758 | | return TryMaterializeDepth( |
| | 8 | 759 | | selected, |
| | 8 | 760 | | positiveSelected ? projectionAxis : -projectionAxis, |
| | 8 | 761 | | out orientedAxis, |
| | 8 | 762 | | out depth, |
| | 8 | 763 | | out depthIsClamped); |
| | | 764 | | } |
| | | 765 | | |
| | | 766 | | private static void CreateSymmetricCapsuleSlabDepth( |
| | | 767 | | Vector3d projectionAxis, |
| | | 768 | | Vector3d shapeCenter, |
| | | 769 | | Vector3d shapeAxis, |
| | | 770 | | Fixed64 shapeLength, |
| | | 771 | | Fixed64 shapeRadius, |
| | | 772 | | bool shapeUsesSphericalRadius, |
| | | 773 | | Vector3d slabCenter, |
| | | 774 | | Vector2d slabCapsuleAxis, |
| | | 775 | | Fixed64 slabCapsuleLength, |
| | | 776 | | Fixed64 slabCapsuleRadius, |
| | | 777 | | Fixed64 slabHalfThickness, |
| | | 778 | | out ProjectionDepth depth) |
| | | 779 | | { |
| | 7 | 780 | | Signed320 shapeAxial = WideArithmetic.MultiplySigned192( |
| | 7 | 781 | | WideArithmetic.Absolute(GetDot(shapeAxis, projectionAxis)), |
| | 7 | 782 | | Signed192.Signed(shapeLength.m_rawValue)); |
| | 7 | 783 | | Signed320 slabRational = CreateCapsuleSlabRational( |
| | 7 | 784 | | projectionAxis, |
| | 7 | 785 | | slabCapsuleAxis, |
| | 7 | 786 | | slabCapsuleLength, |
| | 7 | 787 | | slabHalfThickness); |
| | 7 | 788 | | Signed320 centerRational = WideArithmetic.MultiplySigned192( |
| | 7 | 789 | | WideArithmetic.Absolute(GetDot(slabCenter, shapeCenter, projectionAxis)), |
| | 7 | 790 | | DoubleScale); |
| | 7 | 791 | | depth = new ProjectionDepth( |
| | 7 | 792 | | WideArithmetic.SubtractSigned320( |
| | 7 | 793 | | WideArithmetic.AddSigned320(shapeAxial, slabRational), |
| | 7 | 794 | | centerRational), |
| | 7 | 795 | | GetRationalDenominator(), |
| | 7 | 796 | | shapeUsesSphericalRadius |
| | 7 | 797 | | ? CreateCapsuleRadical(projectionAxis, shapeRadius) |
| | 7 | 798 | | : CreateCylinderRadical( |
| | 7 | 799 | | projectionAxis, |
| | 7 | 800 | | shapeAxis, |
| | 7 | 801 | | shapeRadius), |
| | 7 | 802 | | CreateCapsuleSlabRadical( |
| | 7 | 803 | | projectionAxis, |
| | 7 | 804 | | slabCapsuleRadius)); |
| | 7 | 805 | | } |
| | | 806 | | |
| | | 807 | | private static Signed320 CreateCapsuleSlabRational( |
| | | 808 | | Vector3d projectionAxis, |
| | | 809 | | Vector2d slabCapsuleAxis, |
| | | 810 | | Fixed64 slabCapsuleLength, |
| | | 811 | | Fixed64 slabHalfThickness) |
| | | 812 | | { |
| | 17 | 813 | | var worldSlabAxis = new Vector3d( |
| | 17 | 814 | | slabCapsuleAxis.X, |
| | 17 | 815 | | Fixed64.Zero, |
| | 17 | 816 | | slabCapsuleAxis.Y); |
| | 17 | 817 | | Signed320 planarAxial = WideArithmetic.MultiplySigned192( |
| | 17 | 818 | | WideArithmetic.Absolute(GetDot(worldSlabAxis, projectionAxis)), |
| | 17 | 819 | | Signed192.Signed( |
| | 17 | 820 | | slabCapsuleLength.m_rawValue)); |
| | 17 | 821 | | Signed320 vertical = WideArithmetic.MultiplySigned192( |
| | 17 | 822 | | WideArithmetic.Absolute(GetDot(Vector3d.Up, projectionAxis)), |
| | 17 | 823 | | Signed192.Signed( |
| | 17 | 824 | | slabHalfThickness.m_rawValue)); |
| | 17 | 825 | | return WideArithmetic.AddSigned320( |
| | 17 | 826 | | planarAxial, |
| | 17 | 827 | | WideArithmetic.AddSigned320(vertical, vertical)); |
| | | 828 | | } |
| | | 829 | | |
| | | 830 | | private static Radical CreateCapsuleSlabRadical( |
| | | 831 | | Vector3d projectionAxis, |
| | | 832 | | Fixed64 radius) => |
| | 17 | 833 | | CreateCylinderRadical( |
| | 17 | 834 | | projectionAxis, |
| | 17 | 835 | | Vector3d.Up, |
| | 17 | 836 | | radius); |
| | | 837 | | |
| | | 838 | | private static Radical CreateZeroRadical() => |
| | 3 | 839 | | new(default, ScaleSquared); |
| | | 840 | | |
| | | 841 | | private static Signed192 GetRationalDenominator() |
| | | 842 | | { |
| | 17 | 843 | | Signed320 wide = WideArithmetic.MultiplySigned192( |
| | 17 | 844 | | DoubleScale, |
| | 17 | 845 | | Scale); |
| | 17 | 846 | | return new Signed192( |
| | 17 | 847 | | wide.Word2, |
| | 17 | 848 | | wide.Word1, |
| | 17 | 849 | | wide.Word0); |
| | | 850 | | } |
| | | 851 | | |
| | | 852 | | private static bool IsRadicalAtLeastRatio( |
| | | 853 | | Radical radical, |
| | | 854 | | Signed320 ratioNumerator) => |
| | 5 | 855 | | WideArithmetic.CompareNonNegativeRadicalSumToRatio( |
| | 5 | 856 | | radical.Numerator, |
| | 5 | 857 | | radical.Denominator, |
| | 5 | 858 | | default, |
| | 5 | 859 | | ScaleSquared, |
| | 5 | 860 | | ratioNumerator, |
| | 5 | 861 | | ScaleSquared) >= 0; |
| | | 862 | | |
| | | 863 | | private static int CompareProjectionDepthsWithoutSharedSecond( |
| | | 864 | | ProjectionDepth left, |
| | | 865 | | ProjectionDepth right) |
| | | 866 | | { |
| | 8 | 867 | | Signed576 unit = Signed576.ExtendValue( |
| | 8 | 868 | | Signed320.ExtendValue( |
| | 8 | 869 | | Signed192.Signed(1L))); |
| | 8 | 870 | | return WideArithmetic.CompareRadialProjectionDepths( |
| | 8 | 871 | | Signed704.ExtendValue( |
| | 8 | 872 | | Signed576.ExtendValue( |
| | 8 | 873 | | left.RationalNumerator)), |
| | 8 | 874 | | Signed320.ExtendValue( |
| | 8 | 875 | | left.RationalDenominator), |
| | 8 | 876 | | Signed832.ExtendValue( |
| | 8 | 877 | | left.First.Numerator), |
| | 8 | 878 | | Signed576.ExtendValue( |
| | 8 | 879 | | Signed320.ExtendValue( |
| | 8 | 880 | | left.First.Denominator)), |
| | 8 | 881 | | unit, |
| | 8 | 882 | | Signed704.ExtendValue( |
| | 8 | 883 | | Signed576.ExtendValue( |
| | 8 | 884 | | right.RationalNumerator)), |
| | 8 | 885 | | Signed320.ExtendValue( |
| | 8 | 886 | | right.RationalDenominator), |
| | 8 | 887 | | Signed832.ExtendValue( |
| | 8 | 888 | | right.First.Numerator), |
| | 8 | 889 | | Signed576.ExtendValue( |
| | 8 | 890 | | Signed320.ExtendValue( |
| | 8 | 891 | | right.First.Denominator)), |
| | 8 | 892 | | unit); |
| | | 893 | | } |
| | | 894 | | } |