public override ScanLine DoTask(ScanLine source) { if (source.Count < 5) { //not enough points, less than 5 points surely a false positive return(new ScanLine(source.LaserID, 0)); } ValidityRange range = GetRange(source, Factor); ScanLine ret = new ScanLine(source.LaserID, source.Count); for (int i = 0; i < source.Count; i++) { Point3D sp = source[i]; bool valid = range.IsValid(GetVal(sp)); #if DEBUG if (ColoriseOnly) { Color col = valid ? Color.WhiteSmoke : Color.Red; ret.Add(new Point3D(sp.Position, sp.Normal, col)); } else #endif if (valid) { ret.Add(new Point3D(sp.Position, sp.Normal, sp.Color)); } } return(ret); }
public GoToPremiere(ValidityRange range, int requiredCount) { Require.NotNull(range, "range"); Require.IsTrue(() => requiredCount > 0, "required count should be positive"); Require.IsTrue(() => range.IsDefined(), "range must have definied dates"); ValidityRange = range; RequiredCount = requiredCount; Description = "Go to premiere movies " + requiredCount + " times between " + range.StartDate.Value.ToShortDateString() + " and " + range.EndDate.Value.ToShortDateString(); }
public ValidityRange GetRange(Point3DList source,double factor) { List<int> indexes = new List<int>(source.Count); for (int i = 0; i < source.Count; i++) indexes.Add(i); indexes.Sort(delegate(int x, int y) { return GetVal(source[x]).CompareTo( GetVal(source[y])); } ); double first = GetQuartile(indexes, source, 0.25); double third = GetQuartile(indexes, source, 0.75); double iqr = third - first; ValidityRange ret = new ValidityRange(); ret.Min = first - factor * iqr; ret.Max = third + factor * iqr; return ret ; }
public void Handle(SetConditionCommand command) { PromotionDraft draft = _promotionRepository.GetDraftById(command.PromotionId); if (@command.ConditionType == "GoToPremiere") { var range = ValidityRange.LimitedValidityRange(command.PremierePeriodStart.Value, command.PremierePeriodEnd.Value); draft.SetReceiveCondition(new GoToPremiere(range, command.PremireWatchCount.Value)); } if (@command.ConditionType == "WatchAtSpecificDay") { draft.SetReceiveCondition(new WatchAtSpecificDay(@command.DayToWatch.Value)); } if (@command.ConditionType == "WatchSpecificMovies") { List <Movie> movies = _movieRepository.GetMoviesWithIds(command.MoviesToWatch); draft.SetReceiveCondition(new WatchSpecificMovies(movies)); } }
public ValidityRange GetRange(Point3DList source, double factor) { List <int> indexes = new List <int>(source.Count); for (int i = 0; i < source.Count; i++) { indexes.Add(i); } indexes.Sort(delegate(int x, int y) { return(GetVal(source[x]).CompareTo(GetVal(source[y]))); } ); double first = GetQuartile(indexes, source, 0.25); double third = GetQuartile(indexes, source, 0.75); double iqr = third - first; ValidityRange ret = new ValidityRange(); ret.Min = first - factor * iqr; ret.Max = third + factor * iqr; return(ret); }
public void Handle(SetValidityDatesCommand command) { PromotionDraft draft = _promotionRepository.GetDraftById(command.PromotionId); draft.SetValidityRange(ValidityRange.LimitedValidityRange(command.StartDate.Value, command.EndDate.Value)); }
public bool HasAttendedPremiere(Visitor visitor, ValidityRange validityRange, int requiredCount) { return(true); }