Beispiel #1
0
        public void TransformToPlane(Plane newPlane)
        {
            double eps = 1e-7;

            if (!PipeDataUtil.Equals(Vec.Dot(newPlane.Z, Plane.Z), 1, eps))
            {
                throw new InvalidOperationException("Cannot transform arc to a new plane");
            }
            if (Vec.Difference(newPlane.Origin, Plane.Origin).Length > eps)
            {
                throw new InvalidOperationException("The origins of the planes do not match");
            }

            double angle = Vec.AngleBetween(Plane.X, newPlane.X);

            if (angle < eps)
            {
                return;
            }
            if (Vec.Dot(Vec.Cross(Plane.X, newPlane.X), Plane.Z) < 0)
            {
                angle *= -1;
            }

            Plane = new Plane(Plane.Origin, Plane.X.RotateAbout(Plane.Z, angle),
                              Plane.Y.RotateAbout(Plane.Z, angle));
            StartAngle -= angle;
            EndAngle   -= angle;
        }
Beispiel #2
0
        public static bool CheckContinuity(List <Curve> segs)
        {
            double tolerance = 1e-7;
            int    count     = segs.Count;

            if (count < 2)
            {
                return(true);
            }
            for (int i = 0; i < count - 1; i++)
            {
                double dist = Vec.Difference(segs[i].EndPoint, segs[i + 1].StartPoint).Length;
                if (dist > tolerance)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
 public static bool AreCoincident(Vec a, Vec b)
 {
     return(Vec.Difference(a, b).Length < 1e-6);
 }