示例#1
0
        private Point[] BackwardIncrements(double[] lengths, Point target)
        {
            target = target.Scale(new Size(-1, -1));

            lengths = lengths.Reverse().ToArray();

            List<Point> calculatedPoints = new List<Point>();
            double reachedDistance = lengths[0];
            double angle = 0;

            calculatedPoints.Add(new Point());

            Point[] trianglePoints = null;
            for (int i = 0; i < lengths.Length - 1; i++)
            {
                trianglePoints = CalculateTriangleIK(target, reachedDistance, lengths[i + 1]);
                reachedDistance = trianglePoints.Last().DistanceFromZero;

                angle = Vector.Angle(target.ToVector(), trianglePoints[1].ToVector());
                angle = double.IsNaN(angle) ? 0 : angle;

                RotatePoints(calculatedPoints, angle);
                calculatedPoints.Add(trianglePoints[1]);
            }

            var lastPoint = trianglePoints.Last();
            calculatedPoints.Add(lastPoint);

            var yAxisAngle = -Vector.AngleOriented(new Vector(0, 1), lastPoint.ToVector());

            return calculatedPoints
                .Select(o => { return o - lastPoint; })
                .Reverse()
                .Select(o => { return o.GetRotated(yAxisAngle); })
                .Select(o => { return new Point(-o.X, o.Y); })
                .Select(o => { return o.GetRotated(-yAxisAngle); })
                .ToArray();
        }
示例#2
0
文件: Line.cs 项目: mgrman/DGCLib
 public Line()
 {
     Start = new Point();
     End = new Point();
 }
示例#3
0
文件: Line.cs 项目: mgrman/DGCLib
 public Line(Point start, Point end)
 {
     Start = start;
     End = end;
 }
示例#4
0
 public Rectangle()
 {
     Min = new Point();
     Max = new Point();
 }
示例#5
0
 public Rectangle(Point min, Point max)
 {
     Min = min;
     Max = max;
 }
示例#6
0
 public EL_Point(Point p)
 {
     Position = p;
 }
示例#7
0
 private Point[] CalculateTriangleIK(Point target, double firstLength, double secondLength)
 {
     return IKUtils.GetTriangleIKPositions(target, firstLength, secondLength, false);
 }
示例#8
0
        private Point[] ForwardIncrements(double[] lengths, Point target)
        {
            //TODO
            //dodat lubovolny pociatok
            //tak nejak imnplicitne sa berie (0,0)

            List<Point> calculatedPoints = new List<Point>();
            double reachedDistance = lengths[0];
            double angle = 0;

            calculatedPoints.Add(new Point());

            Point[] trianglePoints = null;
            for (int i = 0; i < lengths.Length - 1; i++)
            {
                trianglePoints = CalculateTriangleIK(target, reachedDistance, lengths[i + 1]);
                reachedDistance = trianglePoints.Last().DistanceFromZero;

                angle = Vector.Angle(target.ToVector(), trianglePoints[1].ToVector());
                angle = double.IsNaN(angle) ? 0 : angle;
                RotatePoints(calculatedPoints, angle);
                calculatedPoints.Add(trianglePoints[1]);
            }

            calculatedPoints.Add(trianglePoints.Last());

            return calculatedPoints.ToArray();
        }