Exemple #1
0
        public RadialInterpolation(Point3D startPoint, Point3D centerPoint, Point3D endPoint, RadialInterpolationDirection direction)
        {
            StartPoint      = startPoint;
            StartFlatPoint  = new Point(startPoint.X, startPoint.Y);
            CenterPoint     = centerPoint;
            CenterFlatPoint = new Point(centerPoint.X, centerPoint.Y);
            EndPoint        = endPoint;
            EndFlatPoint    = new Point(endPoint.X, endPoint.Y);
            Direction       = direction;

            Initialize();
        }
Exemple #2
0
        public RadialInterpolation(Point3D startPoint, Point3D endPoint, double radius, RadialInterpolationDirection direction)
        {
            StartPoint     = startPoint;
            StartFlatPoint = new Point(startPoint.X, startPoint.Y);
            EndPoint       = endPoint;
            EndFlatPoint   = new Point(endPoint.X, endPoint.Y);
            ArcRadius      = radius;
            Direction      = direction;

            ArcHorde = (StartFlatPoint - EndFlatPoint).Length;
            var sidesDoubled = radius * 2;

            var startEndVector = EndFlatPoint - StartFlatPoint;
            var middlePoint    = StartFlatPoint + startEndVector * 0.5;
            var heigth         = Math.Sqrt(sidesDoubled * sidesDoubled - startEndVector.Length * startEndVector.Length) / 2;

            var middleToVertexVector = startEndVector.Rotate(90) * (heigth / startEndVector.Length);

            if (Direction == RadialInterpolationDirection.CounterClockWise)
            {
                CenterFlatPoint = middlePoint + middleToVertexVector;
                CenterPoint     = new Point3D(CenterFlatPoint.X, CenterFlatPoint.Y, EndPoint.Z - StartPoint.Z);
            }
            else
            {
                CenterFlatPoint = middlePoint + (-middleToVertexVector);
                CenterPoint     = new Point3D(CenterFlatPoint.X, CenterFlatPoint.Y, EndPoint.Z - StartPoint.Z);
            }

            const string ENoArcCenter = "Could not find a suitable center for arc";

            if (CenterPoint.X <= double.MinValue)
            {
                throw new Exception(ENoArcCenter);
            }
            if (CenterPoint.Y <= double.MinValue)
            {
                throw new Exception(ENoArcCenter);
            }

            Initialize();
        }