| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using System.Threading.Tasks; |
| | 5 | | using ReFlex.Core.Common.Components; |
| | 6 | | using ReFlex.Core.Common.Interfaces; |
| | 7 | | using ReFlex.Core.Common.Util; |
| | 8 | | using ReFlex.Core.Interactivity.Interfaces; |
| | 9 | | using ReFlex.Core.Interactivity.Util; |
| | 10 | | using Math = System.Math; |
| | 11 | |
|
| | 12 | | namespace ReFlex.Core.Interactivity.Components |
| | 13 | | { |
| | 14 | | public abstract class InteractionObserverBase : IInteractionObserver, IPerformanceReporter |
| | 15 | | { |
| | 16 | | #region Fields |
| | 17 | |
|
| | 18 | | private readonly InteractionSmoothingBehaviour _smoothingBehaviour; |
| 0 | 19 | | private int _numSmoothingFrames = 5; |
| 0 | 20 | | private int _historySize = 25; |
| 0 | 21 | | private int _maxNumEmptyFramesBetween = 3; |
| 0 | 22 | | private float _touchMergeDistance2d = 64f; |
| 0 | 23 | | private float _depthScale = 100.0f; |
| | 24 | | private FilterType _filterType; |
| | 25 | | private float _maxConfidence; |
| | 26 | | private int _extremumTypeCheckRadius; |
| | 27 | | private int _extremumTypeCheckNumSamples; |
| | 28 | |
|
| 0 | 29 | | private Tuple<int, int>[] _fixedSamples = Array.Empty<Tuple<int, int>>(); |
| 0 | 30 | | private Tuple<int, int>[] _stochasticSamples = Array.Empty<Tuple<int, int>>(); |
| | 31 | |
|
| | 32 | | #endregion |
| | 33 | |
|
| | 34 | | #region Properties |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Gets or sets the distance. |
| | 38 | | /// </summary> |
| | 39 | | /// <value> |
| | 40 | | /// The distance. |
| | 41 | | /// </value> |
| 0 | 42 | | public float Distance { get; set; } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Gets or sets the minimum depth. |
| | 46 | | /// </summary> |
| | 47 | | /// <value> |
| | 48 | | /// The maximum depth. |
| | 49 | | /// </value> |
| 0 | 50 | | public float MinDistance { get; set; } |
| | 51 | |
|
| | 52 | | /// <summary> |
| | 53 | | /// Gets or sets the maximum depth. |
| | 54 | | /// </summary> |
| | 55 | | /// <value> |
| | 56 | | /// The maximum depth. |
| | 57 | | /// </value> |
| 0 | 58 | | public float MaxDistance { get; set; } |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// defines how many points should be checked to determine the type of the extremum |
| | 62 | | /// </summary> |
| | 63 | | public int ExtremumTypeCheckNumSamples |
| | 64 | | { |
| 0 | 65 | | get => _extremumTypeCheckNumSamples; |
| | 66 | | set |
| 0 | 67 | | { |
| 0 | 68 | | if (_extremumTypeCheckNumSamples == value) |
| 0 | 69 | | return; |
| 0 | 70 | | _extremumTypeCheckNumSamples = value; |
| 0 | 71 | | UpdateSamples(); |
| 0 | 72 | | } |
| | 73 | | } |
| | 74 | |
|
| | 75 | | /// <summary> |
| | 76 | | /// The pixel radius in which the points are sampled for deriving the type of the local extremum |
| | 77 | | /// </summary> |
| | 78 | | public int ExtremumTypeCheckRadius |
| | 79 | | { |
| 0 | 80 | | get => _extremumTypeCheckRadius; |
| | 81 | | set |
| 0 | 82 | | { |
| 0 | 83 | | if (_extremumTypeCheckRadius == value) |
| 0 | 84 | | return; |
| 0 | 85 | | _extremumTypeCheckRadius = value; |
| 0 | 86 | | UpdateSamples(); |
| 0 | 87 | | } |
| | 88 | | } |
| | 89 | |
|
| | 90 | | /// <summary> |
| | 91 | | /// Which ratio of "correctly aligned" points should match to distinguish between Undefined or Minimum/Maximum ? |
| | 92 | | /// </summary> |
| 0 | 93 | | public float ExtremumTypeCheckFittingPercentage { get; set; } |
| | 94 | |
|
| | 95 | | /// <summary> |
| | 96 | | /// Defines how neighboring the points are sampled for determining the type of extremum. |
| | 97 | | /// </summary> |
| 0 | 98 | | public ExtremumTypeCheckMethod ExtremumTypeCheckMethod { get; set; } |
| | 99 | |
|
| | 100 | | public int InteractionHistorySize |
| | 101 | | { |
| 0 | 102 | | get => _historySize; |
| | 103 | | set |
| 0 | 104 | | { |
| 0 | 105 | | _historySize = value; |
| 0 | 106 | | if (_smoothingBehaviour != null) |
| 0 | 107 | | { |
| 0 | 108 | | _smoothingBehaviour.NumFramesHistory = value; |
| | 109 | | // update depending smoothing/filter values |
| 0 | 110 | | NumSmoothingFrames = _numSmoothingFrames; |
| 0 | 111 | | MaxNumEmptyFramesBetween = _maxNumEmptyFramesBetween; |
| 0 | 112 | | } |
| 0 | 113 | | } |
| | 114 | | } |
| | 115 | |
|
| | 116 | | public int NumSmoothingFrames |
| | 117 | | { |
| 0 | 118 | | get => _numSmoothingFrames; |
| | 119 | | set |
| 0 | 120 | | { |
| 0 | 121 | | _numSmoothingFrames = value; |
| 0 | 122 | | if (_smoothingBehaviour != null) |
| 0 | 123 | | _smoothingBehaviour.NumFramesSmoothing = value < _smoothingBehaviour.NumFramesHistory |
| 0 | 124 | | ? _smoothingBehaviour.NumFramesHistory |
| 0 | 125 | | : value; |
| 0 | 126 | | } |
| | 127 | | } |
| | 128 | |
|
| | 129 | | // TODO: write tests for negative (!) values and values larger than history |
| | 130 | | public int MaxNumEmptyFramesBetween |
| | 131 | | { |
| 0 | 132 | | get => _maxNumEmptyFramesBetween; |
| | 133 | | set |
| 0 | 134 | | { |
| 0 | 135 | | _maxNumEmptyFramesBetween = value; |
| 0 | 136 | | if (_smoothingBehaviour != null) |
| 0 | 137 | | _smoothingBehaviour.MaxNumEmptyFramesBetween = value < _smoothingBehaviour.NumFramesHistory |
| 0 | 138 | | ? _smoothingBehaviour.NumFramesHistory |
| 0 | 139 | | : value; |
| 0 | 140 | | } |
| | 141 | | } |
| | 142 | |
|
| | 143 | | public float TouchMergeDistance2D |
| | 144 | | { |
| 0 | 145 | | get => _touchMergeDistance2d; |
| | 146 | | set |
| 0 | 147 | | { |
| 0 | 148 | | _touchMergeDistance2d = value; |
| 0 | 149 | | if (_smoothingBehaviour != null) |
| 0 | 150 | | _smoothingBehaviour.TouchMergeDistance2D = value; |
| 0 | 151 | | } |
| | 152 | | } |
| | 153 | |
|
| | 154 | | public float DepthScale |
| | 155 | | { |
| 0 | 156 | | get => _depthScale; |
| | 157 | | set |
| 0 | 158 | | { |
| 0 | 159 | | _depthScale = value; |
| 0 | 160 | | if (_smoothingBehaviour != null) |
| 0 | 161 | | _smoothingBehaviour.DepthScale = value; |
| 0 | 162 | | } |
| | 163 | | } |
| | 164 | |
|
| | 165 | | public FilterType FilterType |
| | 166 | | { |
| 0 | 167 | | get => _filterType; |
| | 168 | | set |
| 0 | 169 | | { |
| 0 | 170 | | _filterType = value; |
| 0 | 171 | | if (_smoothingBehaviour != null) |
| 0 | 172 | | _smoothingBehaviour.UpdateFilterType(_filterType); |
| 0 | 173 | | } |
| | 174 | | } |
| | 175 | |
|
| | 176 | |
|
| | 177 | | /// <summary> |
| | 178 | | /// Gets or sets the minimum angle. |
| | 179 | | /// </summary> |
| | 180 | | /// <value> |
| | 181 | | /// The minimum angle. |
| | 182 | | /// </value> |
| 0 | 183 | | public virtual float MinAngle { get; set; } |
| | 184 | |
|
| | 185 | | /// <summary> |
| | 186 | | /// Gets or sets the minimum confidence. |
| | 187 | | /// </summary> |
| | 188 | | /// <value> |
| | 189 | | /// The minimum confidence. |
| | 190 | | /// </value> |
| 0 | 191 | | public virtual float MinConfidence { get; set; } |
| | 192 | |
|
| | 193 | | /// <summary> |
| | 194 | | /// Gets or sets the maximum confidence. |
| | 195 | | /// </summary> |
| | 196 | | /// <value> |
| | 197 | | /// The maximum confidence. |
| | 198 | | /// </value> |
| | 199 | | public virtual float MaxConfidence |
| | 200 | | { |
| 0 | 201 | | get => _maxConfidence; |
| | 202 | | set |
| 0 | 203 | | { |
| 0 | 204 | | _maxConfidence = value; |
| 0 | 205 | | if (_smoothingBehaviour != null) |
| 0 | 206 | | _smoothingBehaviour.MaxConfidence = (int) MaxConfidence; |
| 0 | 207 | | } |
| | 208 | | } |
| | 209 | |
|
| 0 | 210 | | public bool MeasurePerformance { get; set; } |
| | 211 | |
|
| 0 | 212 | | protected int FrameId { get; private set; } |
| | 213 | |
|
| | 214 | | #region Abstract Members |
| | 215 | |
|
| | 216 | | public abstract ObserverType Type { get; } |
| | 217 | | public abstract PointCloud3 PointCloud { get; set; } |
| | 218 | | public abstract VectorField2 VectorField { get; set; } |
| | 219 | |
|
| | 220 | | public abstract event EventHandler<IList<Interaction>> NewInteractions; |
| | 221 | |
|
| | 222 | | public event EventHandler<PerformanceDataItem> PerformanceDataUpdated; |
| | 223 | |
|
| | 224 | | public event EventHandler<IList<InteractionFrame>> InteractionHistoryUpdated; |
| | 225 | |
|
| | 226 | | public abstract Task<ProcessingResult> Update(); |
| | 227 | |
|
| | 228 | | #endregion |
| | 229 | |
|
| | 230 | | #region Constructor |
| | 231 | |
|
| 0 | 232 | | protected InteractionObserverBase() |
| 0 | 233 | | { |
| 0 | 234 | | _smoothingBehaviour = new InteractionSmoothingBehaviour(InteractionHistorySize); |
| 0 | 235 | | } |
| | 236 | |
|
| | 237 | | #endregion |
| | 238 | |
|
| | 239 | | public void UpdateFrameId(int frameId) |
| 0 | 240 | | { |
| 0 | 241 | | FrameId = frameId; |
| 0 | 242 | | } |
| | 243 | |
|
| | 244 | | #endregion |
| | 245 | |
|
| | 246 | | protected InteractionFrame ComputeSmoothingValue(IList<Interaction> rawInteractions) |
| 0 | 247 | | { |
| 0 | 248 | | var result = _smoothingBehaviour.Update(rawInteractions); |
| 0 | 249 | | InteractionHistoryUpdated?.Invoke(this, _smoothingBehaviour.InteractionsFramesCache); |
| | 250 | |
|
| 0 | 251 | | return result; |
| 0 | 252 | | } |
| | 253 | |
|
| | 254 | | protected virtual ExtremumDescription ComputeExtremumType(Point3[][] pointsArray, int xPos, int yPos) |
| 0 | 255 | | { |
| 0 | 256 | | if (ExtremumTypeCheckMethod == ExtremumTypeCheckMethod.Global) |
| 0 | 257 | | return new ExtremumDescription |
| 0 | 258 | | { Type = ExtremumType.Maximum, NumFittingPoints = ExtremumTypeCheckNumSamples, PercentageFittingPoin |
| | 259 | |
|
| 0 | 260 | | var xMax = pointsArray.Length - 1; |
| 0 | 261 | | var yMax = xMax > 0 ? pointsArray[0].Length - 1 : 0; |
| | 262 | |
|
| | 263 | | // refZ is the absolute distance from sensor |
| 0 | 264 | | var refZ = Math.Abs(pointsArray[xPos][yPos].Z); |
| | 265 | |
|
| 0 | 266 | | var numCloser = 0; |
| 0 | 267 | | var numFarther = 0; |
| | 268 | |
|
| | 269 | | Tuple<int, int>[] samples; |
| 0 | 270 | | switch (ExtremumTypeCheckMethod) |
| | 271 | | { |
| | 272 | | case ExtremumTypeCheckMethod.StochasticStatic: |
| 0 | 273 | | samples = _stochasticSamples; |
| 0 | 274 | | break; |
| | 275 | | case ExtremumTypeCheckMethod.StochasticDynamic: |
| 0 | 276 | | samples = GenerateSamples(); |
| 0 | 277 | | break; |
| | 278 | | case ExtremumTypeCheckMethod.Global: |
| 0 | 279 | | throw new ArgumentException("invalid Method 'Global' at this point."); |
| | 280 | | case ExtremumTypeCheckMethod.FixedRadius: |
| | 281 | | default: |
| 0 | 282 | | samples = _fixedSamples; |
| 0 | 283 | | break; |
| | 284 | | } |
| | 285 | |
|
| 0 | 286 | | for (var i = 0; i < samples.Length; i++) |
| 0 | 287 | | { |
| 0 | 288 | | var sample = GetSample(pointsArray, xPos, yPos, samples, i, xMax, yMax); |
| 0 | 289 | | if (Math.Abs(sample.Z) > refZ) |
| 0 | 290 | | numFarther++; |
| | 291 | | else |
| 0 | 292 | | numCloser++; |
| 0 | 293 | | } |
| | 294 | |
|
| | 295 | |
|
| 0 | 296 | | var ratioMax = ExtremumTypeCheckNumSamples > 0 ? (float)numCloser / ExtremumTypeCheckNumSamples : 0; |
| 0 | 297 | | var ratioMin = ExtremumTypeCheckNumSamples > 0 ? (float)numFarther / ExtremumTypeCheckNumSamples : 0; |
| | 298 | |
|
| 0 | 299 | | if (numCloser > numFarther && ratioMax > ExtremumTypeCheckFittingPercentage) |
| 0 | 300 | | { |
| 0 | 301 | | return new ExtremumDescription |
| 0 | 302 | | { |
| 0 | 303 | | Type = ExtremumType.Maximum, |
| 0 | 304 | | NumFittingPoints = numCloser, |
| 0 | 305 | | PercentageFittingPoints = ratioMax |
| 0 | 306 | | }; |
| | 307 | | } |
| | 308 | |
|
| 0 | 309 | | if (numFarther > numCloser && ratioMin > ExtremumTypeCheckFittingPercentage) |
| 0 | 310 | | { |
| 0 | 311 | | return new ExtremumDescription |
| 0 | 312 | | { |
| 0 | 313 | | Type = ExtremumType.Minimum, |
| 0 | 314 | | NumFittingPoints = numFarther, |
| 0 | 315 | | PercentageFittingPoints = ratioMin |
| 0 | 316 | | }; |
| | 317 | | } |
| | 318 | |
|
| 0 | 319 | | return new ExtremumDescription |
| 0 | 320 | | { |
| 0 | 321 | | Type = ExtremumType.Undefined, |
| 0 | 322 | | NumFittingPoints = Math.Max(numCloser, numFarther), |
| 0 | 323 | | PercentageFittingPoints = Math.Max(ratioMin, ratioMax) |
| 0 | 324 | | }; |
| | 325 | |
|
| 0 | 326 | | } |
| | 327 | |
|
| | 328 | | protected List<Interaction> ConvertDepthValue(List<Interaction> interactions) |
| 0 | 329 | | { |
| 0 | 330 | | var result = new List<Interaction>(); |
| | 331 | |
|
| 0 | 332 | | foreach (var item in interactions) |
| 0 | 333 | | { |
| 0 | 334 | | if (item == null) |
| 0 | 335 | | continue; |
| | 336 | |
|
| 0 | 337 | | if (item.Position.Z < Distance) |
| 0 | 338 | | { |
| 0 | 339 | | var depth = (Distance - item.Position.Z - MinDistance) / (MinDistance - MaxDistance); |
| | 340 | |
|
| 0 | 341 | | if (depth > 0) |
| 0 | 342 | | continue; |
| | 343 | |
|
| 0 | 344 | | if (depth < -1) |
| 0 | 345 | | depth = -1; |
| | 346 | |
|
| 0 | 347 | | item.Position.Z = depth; |
| 0 | 348 | | } |
| | 349 | | else |
| 0 | 350 | | { |
| 0 | 351 | | var depth = (item.Position.Z - MinDistance - Distance) / (MaxDistance - MinDistance); |
| | 352 | |
|
| 0 | 353 | | if (depth < 0) |
| 0 | 354 | | continue; |
| | 355 | |
|
| 0 | 356 | | if (depth > 1) |
| 0 | 357 | | depth = 1; |
| | 358 | |
|
| 0 | 359 | | item.Position.Z = depth; |
| 0 | 360 | | } |
| | 361 | |
|
| 0 | 362 | | result.Add(item); |
| 0 | 363 | | } |
| | 364 | |
|
| 0 | 365 | | return result; |
| 0 | 366 | | } |
| | 367 | |
|
| | 368 | | protected IEnumerable<Interaction> ApplyConfidenceFilter(IEnumerable<Interaction> interactions) |
| 0 | 369 | | { |
| 0 | 370 | | return interactions.ToArray().Where(item => item.Confidence > MinConfidence); |
| 0 | 371 | | } |
| | 372 | |
|
| | 373 | | protected List<Interaction> ComputeExtremumType(List<Interaction> interactions, Point3[][] pointsArray) |
| 0 | 374 | | { |
| 0 | 375 | | interactions.ForEach(interaction => |
| 0 | 376 | | interaction.ExtremumDescription = ComputeExtremumType(pointsArray, (int)interaction.Position.X, (int)int |
| | 377 | |
|
| 0 | 378 | | return interactions; |
| 0 | 379 | | } |
| | 380 | |
|
| | 381 | | /// <summary> |
| | 382 | | /// generic approach: removes all maximums below the surface and all minimums above the surface. Removal is base |
| | 383 | | /// Points witch <see cref="ExtremumType.Undefined"/> are also removed. |
| | 384 | | /// </summary> |
| | 385 | | /// <param name="interactions">the list of preprocessed interactions with valid ExtremumDescription</param> |
| | 386 | | /// <returns></returns> |
| | 387 | | protected List<Interaction> RemoveExtremumsBetweenTouches(List<Interaction> interactions) |
| 0 | 388 | | { |
| 0 | 389 | | return interactions.Where((touch) => |
| 0 | 390 | | // invalid or undefined ExtremumType |
| 0 | 391 | | touch.ExtremumDescription != null && touch.ExtremumDescription.Type != ExtremumType.Undefined && |
| 0 | 392 | | // minimums below the surface |
| 0 | 393 | | ((touch.Position.Z < 0 && touch.ExtremumDescription.Type == ExtremumType.Minimum) || |
| 0 | 394 | | // maximums above the surface |
| 0 | 395 | | (touch.Position.Z > 0 && touch.ExtremumDescription.Type == ExtremumType.Maximum)) |
| 0 | 396 | |
|
| 0 | 397 | | ).ToList(); |
| 0 | 398 | | } |
| | 399 | |
|
| | 400 | | protected void UpdatePerformanceMetrics(ProcessPerformance perfItem) |
| 0 | 401 | | { |
| 0 | 402 | | var pData = new PerformanceDataItem |
| 0 | 403 | | { |
| 0 | 404 | | FrameId = Convert.ToInt32(FrameId), |
| 0 | 405 | | FrameStart = DateTime.Now.Ticks, |
| 0 | 406 | | Process = perfItem, |
| 0 | 407 | | Stage = PerformanceDataStage.ProcessingData |
| 0 | 408 | | }; |
| | 409 | |
|
| 0 | 410 | | PerformanceDataUpdated?.Invoke(this, pData); |
| 0 | 411 | | } |
| | 412 | |
|
| | 413 | | protected void UpdateInteractionFrames(List<Interaction> cleanedUpInteractions, InteractionFrame currentFrame) |
| 0 | 414 | | { |
| 0 | 415 | | currentFrame.Interactions.ForEach((interaction) => |
| 0 | 416 | | { |
| 0 | 417 | | if (cleanedUpInteractions.FirstOrDefault((i) => i.TouchId == interaction.TouchId) == null) |
| 0 | 418 | | { |
| 0 | 419 | | if (interaction.Confidence > 0) |
| 0 | 420 | | interaction.Confidence--; |
| 0 | 421 | | } |
| 0 | 422 | | }); |
| | 423 | |
|
| 0 | 424 | | currentFrame.Interactions.RemoveAll((interaction) => interaction.Confidence <= 0); |
| | 425 | |
|
| 0 | 426 | | _smoothingBehaviour.UpdateCachedFrame(currentFrame); |
| 0 | 427 | | InteractionHistoryUpdated?.Invoke(this, _smoothingBehaviour.InteractionsFramesCache); |
| 0 | 428 | | } |
| | 429 | |
|
| | 430 | | /// <summary> |
| | 431 | | /// Calculates the average distance for the currently stored PointCloud. |
| | 432 | | /// </summary> |
| | 433 | | /// <returns></returns> |
| | 434 | | public float CalculateAverageDistance() |
| 0 | 435 | | { |
| 0 | 436 | | var sum = 0f; |
| 0 | 437 | | var points = PointCloud?.AsArray(); |
| | 438 | |
|
| 0 | 439 | | if (points == null) |
| 0 | 440 | | return sum; |
| | 441 | |
|
| 0 | 442 | | var numValidSamples = 0; |
| | 443 | |
|
| 0 | 444 | | for (var i = 0; i < points.Length; ++i) |
| 0 | 445 | | { |
| 0 | 446 | | if (!points[i].IsValid || points[i].IsFiltered) |
| 0 | 447 | | continue; |
| | 448 | |
|
| 0 | 449 | | numValidSamples++; |
| 0 | 450 | | sum += points[i].Z; |
| 0 | 451 | | } |
| | 452 | |
|
| 0 | 453 | | return (float) decimal.Round((decimal) (sum / numValidSamples), 2); |
| 0 | 454 | | } |
| | 455 | |
|
| | 456 | | private static Point3 GetSample(Point3[][] pointsArray, int xPos, int yPos, Tuple<int, int>[] samples, int i, in |
| 0 | 457 | | { |
| 0 | 458 | | var xIdx = xPos + samples[i].Item1; |
| 0 | 459 | | xIdx = Math.Min(Math.Max(xIdx, 0), xMax); |
| | 460 | |
|
| 0 | 461 | | var yIdx = yPos + samples[i].Item2; |
| 0 | 462 | | yIdx = Math.Min(Math.Max(yIdx, 0), yMax); |
| 0 | 463 | | var sample = pointsArray[xIdx][yIdx]; |
| | 464 | |
|
| 0 | 465 | | return sample; |
| 0 | 466 | | } |
| | 467 | |
|
| | 468 | | private Tuple<int, int>[] GenerateSamples() |
| 0 | 469 | | { |
| 0 | 470 | | var result = new List<Tuple<int, int>>(); |
| | 471 | |
|
| 0 | 472 | | var rnd = new Random(); |
| | 473 | |
|
| 0 | 474 | | var min = (int)Math.Floor(0.5f * ExtremumTypeCheckRadius); |
| 0 | 475 | | var max = ExtremumTypeCheckRadius; |
| | 476 | |
|
| 0 | 477 | | for (var i = 0; i < ExtremumTypeCheckNumSamples; i++) |
| 0 | 478 | | { |
| 0 | 479 | | var xStochastic = rnd.Next(min, max); |
| 0 | 480 | | var yStochastic = rnd.Next(min, max); |
| | 481 | |
|
| 0 | 482 | | result.Add(new Tuple<int, int>(xStochastic, yStochastic)); |
| 0 | 483 | | } |
| | 484 | |
|
| 0 | 485 | | return result.ToArray(); |
| 0 | 486 | | } |
| | 487 | |
|
| | 488 | | private void UpdateSamples() |
| 0 | 489 | | { |
| 0 | 490 | | var samplesFixed = new List<Tuple<int, int>>(); |
| | 491 | |
|
| 0 | 492 | | for (var i = 0; i < ExtremumTypeCheckNumSamples; i++) |
| 0 | 493 | | { |
| 0 | 494 | | var p = (float)i / ExtremumTypeCheckRadius; |
| 0 | 495 | | var xFixed = (int) Math.Floor(ExtremumTypeCheckRadius * Math.Cos(p * 2 * Math.PI)); |
| 0 | 496 | | var yFixed = (int) Math.Floor(ExtremumTypeCheckRadius * Math.Sin(p * 2 * Math.PI)); |
| | 497 | |
|
| 0 | 498 | | samplesFixed.Add(new Tuple<int, int>(xFixed, yFixed)); |
| 0 | 499 | | } |
| 0 | 500 | | _fixedSamples = samplesFixed.ToArray(); |
| | 501 | |
|
| 0 | 502 | | _stochasticSamples = GenerateSamples(); |
| 0 | 503 | | } |
| | 504 | | } |
| | 505 | | } |