Example #1
0
        //ToDo: könnte für lineare Interpolation optimiert werden (Verzicht auf binäre Suche) (dann nicht mehr static)
        public static TrajectoryPoint[] getEquidistantPoints(IStrokeInterpolation s, int nNewPoints)
        {
            if (nNewPoints < 2)
            {
                throw new ArgumentException("Stroke muss in mindestens 2 Abschnitte eingeteilt werden", "nNewPoints");
            }

            var result = new TrajectoryPoint[nNewPoints];

            //first one is clear
            result[0] = s.getByArcLength(0);

            var stepSize  = s.ArcLength / (nNewPoints - 1);
            var curArcLen = stepSize;

            for (int j = 1; j < nNewPoints - 1; j++)
            {
                result[j]  = s.getByArcLength(curArcLen);
                curArcLen += stepSize;
            }

            //last one is also clear
            result[nNewPoints - 1] = s.getByArcLength(s.ArcLength);

            return(result);
        }
Example #2
0
        //ToDo: könnte für lineare Interpolation optimiert werden (Verzicht auf binäre Suche) (dann nicht mehr static)
        public static TrajectoryPoint[] getPointsByDistance(IStrokeInterpolation s, double distance)
        {
            if (distance <= double.Epsilon)
            {
                throw new ArgumentException("Distanz muss größer sein", "distance");
            }

            var nPoints = (int)(s.ArcLength / distance);

            var result = new TrajectoryPoint[nPoints];

            var curArcLen = distance;

            for (int i = 0; i < nPoints; i++)
            {
                result[i]  = s.getByArcLength(curArcLen);
                curArcLen += distance;
            }

            //what about points exactly at or close to the end?

            return(result);
        }