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

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

                var result = new TrajectoryPoint3D[nPoints];

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

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

                return(result);
            }

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

                var result = new TrajectoryPoint3D[nNewPoints];

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

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

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

                return(result);
            }

            throw new NotImplementedException();
        }