< Summary - ReFlex - Library

Information
Class: ReFlex.Core.Common.Components.InteractionVelocity
Assembly: ReFlex.Core.Common
File(s): D:\a\reflex\reflex\library\src\Core\Common\Components\InteractionVelocity.cs
Line coverage
80%
Covered lines: 32
Uncovered lines: 8
Coverable lines: 40
Total lines: 61
Line coverage: 80%
Branch coverage
33%
Covered branches: 4
Total branches: 12
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_TouchId()100%11100%
get_FrameId()100%11100%
get_LastMeasuredFrameId()100%11100%
get_TimestampSeconds()100%11100%
get_LastMeasuredTimestampSeconds()100%11100%
get_PredictionTimestampSeconds()100%11100%
get_PredictionHorizonSeconds()100%11100%
get_Confidence()100%11100%
get_SampleCount()100%11100%
get_IsPredicted()100%11100%
get_IsPublished()100%11100%
get_SuppressionReason()100%11100%
get_UseSecondDerivation()100%11100%
get_Width()100%11100%
get_Height()100%11100%
get_MeasuredPosition()100%11100%
get_SmoothedPosition()100%11100%
get_MatchingPosition()100%11100%
get_FirstDerivation()100%11100%
get_SecondDerivation()100%11100%
get_PredictedPositionBasic()100%11100%
get_PredictedPositionAdvanced()100%11100%
.ctor()100%11100%
.ctor(...)0%2040%
Update(...)50%8881.81%

File(s)

D:\a\reflex\reflex\library\src\Core\Common\Components\InteractionVelocity.cs

#LineLine coverage
 1using System;
 2
 3namespace ReFlex.Core.Common.Components
 4{
 5    /// <summary>
 6    /// Motion in raster coordinates per second (Z is normalized depth); acceleration is units/s².
 7    /// Both forecasts target PredictionTimestampSeconds. FrameId identifies the latest processed
 8    /// observation; LastMeasuredFrameId identifies the contact's last real measurement. Lost contacts
 9    /// retain that measurement and its smoothed position. Diagnostics are never fed
 10    /// back as measurements. Derivatives are evaluated at the last measurement time.
 11    /// </summary>
 12    public class InteractionVelocity
 13    {
 52814        public int TouchId { get; set; }
 27015        public int FrameId { get; set; }
 26216        public int LastMeasuredFrameId { get; set; }
 26417        public double TimestampSeconds { get; set; }
 26218        public double LastMeasuredTimestampSeconds { get; set; }
 27419        public double PredictionTimestampSeconds { get; set; }
 26220        public double PredictionHorizonSeconds { get; set; }
 26621        public float Confidence { get; set; }
 28222        public int SampleCount { get; set; }
 53423        public bool IsPredicted { get; set; }
 46624        public bool IsPublished { get; set; }
 143425        public string SuppressionReason { get; set; } = "";
 26226        public bool UseSecondDerivation { get; set; }
 20827        public int Width { get; set; }
 20828        public int Height { get; set; }
 245029        public Point3 MeasuredPosition { get; set; } = new Point3();
 148430        public Point3 SmoothedPosition { get; set; } = new Point3();
 149431        public Point3 MatchingPosition { get; set; } = new Point3();
 247432        public Point3 FirstDerivation { get; set; } = new Point3();
 246033        public Point3 SecondDerivation { get; set; } = new Point3();
 463034        public Point3 PredictedPositionBasic { get; set; } = new Point3();
 249635        public Point3 PredictedPositionAdvanced { get; set; } = new Point3();
 36
 366637        public InteractionVelocity() { }
 38
 039        public InteractionVelocity(int touchId, Point3 position, Point3 firstDerivation = null,
 040            Point3 secondDerivation = null, float secondDerivationMagnitude = .5f)
 041        {
 042            TouchId = touchId;
 043            Update(position, firstDerivation ?? new Point3(), secondDerivation ?? new Point3(), secondDerivationMagnitud
 044        }
 45
 46        /// <summary>h is seconds. p(t+h) = p(t) + v(t) h + magnitude a(t) h²; .5 gives constant acceleration.</summary>
 47        public void Update(Point3 position, Point3 firstDerivation, Point3 secondDerivation,
 48            float secondDerivationMagnitude = .5f, float horizon = 1)
 122249        {
 122250            if (!float.IsFinite(horizon) || horizon < 0)
 051                throw new ArgumentOutOfRangeException(nameof(horizon));
 122252            if (!float.IsFinite(secondDerivationMagnitude) || secondDerivationMagnitude < 0)
 053                throw new ArgumentOutOfRangeException(nameof(secondDerivationMagnitude));
 122254            MeasuredPosition = (Point3)position.Copy();
 122255            FirstDerivation = (Point3)firstDerivation.Copy();
 122256            SecondDerivation = (Point3)secondDerivation.Copy();
 122257            PredictedPositionBasic = position + firstDerivation * horizon;
 122258            PredictedPositionAdvanced = PredictedPositionBasic + secondDerivation * (secondDerivationMagnitude * horizon
 122259        }
 60    }
 61}