private UserDistance DetermineZone(UserDistance oldUserDistance, float trackedSkeletonDistance) { UserDistance newUserDistance; if (IsInZone(0.0f, this.NearBoundary - this.NearBoundaryHysteresis, trackedSkeletonDistance)) { newUserDistance = UserDistance.Touch; } else if (IsInZone(this.NearBoundary + this.NearBoundaryHysteresis, this.FarBoundary - this.FarBoundaryHysteresis, trackedSkeletonDistance)) { newUserDistance = UserDistance.Medium; } else if (IsInZone(this.FarBoundary + this.FarBoundaryHysteresis, float.MaxValue, trackedSkeletonDistance)) { newUserDistance = UserDistance.Far; } else if (oldUserDistance != UserDistance.Unknown) { // the skeleton is in one of the border areas. Since there // was a previous state, leave things in the prevoius state newUserDistance = oldUserDistance; } else if (IsInZone(this.NearBoundary - this.NearBoundaryHysteresis, this.NearBoundary + this.NearBoundaryHysteresis, trackedSkeletonDistance)) { // User appeared near the touch and medium border so say they are in the medium area newUserDistance = UserDistance.Medium; } else { // User appeared in the far zone newUserDistance = UserDistance.Far; } return(newUserDistance); }
private void OnUserDistanceChanged(UserDistance oldValue, UserDistance newValue) { this.adaptiveUIPlacementHelper.Parent = this.Parent as FrameworkElement; switch (newValue) { case UserDistance.Unknown: case UserDistance.Far: this.Visibility = Visibility.Collapsed; break; case UserDistance.Medium: this.Visibility = Visibility.Visible; this.StartingButton.Visibility = Visibility.Visible; this.InformationButton.Visibility = Visibility.Hidden; this.FadeOutOverlay.Visibility = Visibility.Hidden; if (oldValue != UserDistance.Touch) { this.adaptiveUIPlacementHelper.UpdatePlacement(this.Settings.FarBoundary - this.Settings.BoundaryHysteresis); } break; case UserDistance.Touch: this.Visibility = Visibility.Visible; this.FadeOutOverlay.Visibility = Visibility.Visible; break; default: throw new ArgumentOutOfRangeException("newValue"); } }
private void AdaptiveZoneLogicPropertyChanged(object sender, PropertyChangedEventArgs args) { this.KinectRegion.IsCursorVisible = (this.adaptiveZoneLogic.UserDistance == UserDistance.Far) || (this.adaptiveZoneLogic.UserDistance == UserDistance.Medium); this.AttractTextBlock.Visibility = (this.adaptiveZoneLogic.UserDistance == UserDistance.Far) ? Visibility.Visible : Visibility.Hidden; UpdateUserViewerVisibility(); this.UserDistance = this.adaptiveZoneLogic.UserDistance; this.SomethingNearSensor = this.adaptiveZoneLogic.SomethingNearSensor; this.TimeoutWarning = this.adaptiveZoneLogic.TimeoutWarning; }
private void OnUserDistanceChanged(UserDistance userDistance) { this.adaptiveUIPlacementHelper.Parent = this.Parent as FrameworkElement; switch (userDistance) { case UserDistance.Unknown: case UserDistance.Far: case UserDistance.Medium: this.Visibility = Visibility.Collapsed; break; case UserDistance.Touch: this.Visibility = Visibility.Visible; this.adaptiveUIPlacementHelper.UpdatePlacement(this.Settings.NearBoundary - this.Settings.BoundaryHysteresis); break; default: throw new ArgumentOutOfRangeException("userDistance"); } }
public async Task <double> Handle(CreateAndCalculateDistanceCommand request, CancellationToken cancellationToken) { double R = 6371; // km double sLat1 = Math.Sin(ToRadians(request.Lat1)); double sLat2 = Math.Sin(ToRadians(request.Lat2)); double cLat1 = Math.Cos(ToRadians(request.Lat1)); double cLat2 = Math.Cos(ToRadians(request.Lat2)); double cLon = Math.Cos(ToRadians(request.Lon1) - ToRadians(request.Lon2)); double cosD = sLat1 * sLat2 + cLat1 * cLat2 * cLon; double d = Math.Acos(cosD); double dist = R * d; var entity = new UserDistance { FromPoint = new Domain.Location { Latitude = request.Lat1, Longitude = request.Lon1 }, ToPoint = new Domain.Location { Latitude = request.Lat2, Longitude = request.Lon2, }, Distance = dist, UserId = _currentUserService.UserId, Created = DateTime.Now, LastModified = DateTime.Now, }; _db.UserDistances.Add(entity); await _db.SaveChangesAsync(cancellationToken); return(dist); }
private UserDistance DetermineZone(UserDistance oldUserDistance, float trackedSkeletonDistance) { UserDistance newUserDistance; if (IsInZone(0.0f, this.NearBoundary - this.NearBoundaryHysteresis, trackedSkeletonDistance)) { newUserDistance = UserDistance.Touch; } else if (IsInZone(this.NearBoundary + this.NearBoundaryHysteresis, this.FarBoundary - this.FarBoundaryHysteresis, trackedSkeletonDistance)) { newUserDistance = UserDistance.Medium; } else if (IsInZone(this.FarBoundary + this.FarBoundaryHysteresis, float.MaxValue, trackedSkeletonDistance)) { newUserDistance = UserDistance.Far; } else if (oldUserDistance != UserDistance.Unknown) { // the skeleton is in one of the border areas. Since there // was a previous state, leave things in the prevoius state newUserDistance = oldUserDistance; } else if (IsInZone(this.NearBoundary - this.NearBoundaryHysteresis, this.NearBoundary + this.NearBoundaryHysteresis, trackedSkeletonDistance)) { // User appeared near the touch and medium border so say they are in the medium area newUserDistance = UserDistance.Medium; } else { // User appeared in the far zone newUserDistance = UserDistance.Far; } return newUserDistance; }
private void AdaptiveZoneLogicPropertyChanged(object sender, PropertyChangedEventArgs args) { this.UserDistance = this.adaptiveZoneLogic.UserDistance; this.SomethingNearSensor = this.adaptiveZoneLogic.SomethingNearSensor; }