Example #1
0
        public Ellipse ProjectParallelOn(Plane plane, Vector3d viewDirection)
        {
            if (viewDirection.IsOrthogonalTo(plane.NormalVector))
            {
                throw new ArgumentException("View direction parallel to projection plane!");
            }
            if (viewDirection.IsOrthogonalTo(this.NormalVector))
            {
                throw new ArgumentException("View direction parallel to circle!");
            }
            Point point  = this.point_0 + this.SemimajorAxisVector.ToPoint();
            Point point2 = this.Center + this.SemiminorAxisVector.ToPoint();
            Point p      = point.ProjectParallelOn(plane, viewDirection);
            Point q      = point2.ProjectParallelOn(plane, viewDirection);
            Point m      = this.Center.ProjectParallelOn(plane, viewDirection);

            return(Ellipse.ConstructFromConjugateDiameters(m, p, q));
        }
Example #2
0
        public Vector3d ProjectParallelOn(Plane plane, Vector3d viewDirection)
        {
            if (viewDirection.IsOrthogonalTo(plane.NormalVector))
            {
                throw new ArgumentException("Projection error: view direction is parallel to projection plane!");
            }
            Point left  = this.ToPoint().ProjectParallelOn(plane, viewDirection);
            Point right = new Point(0.0, 0.0, 0.0).ProjectParallelOn(plane, viewDirection);

            return(new Vector3d(left - right));
        }
Example #3
0
 public Edge ProjectParallelOn(Plane plane, Vector3d viewDirection)
 {
     if (viewDirection.IsOrthogonalTo(plane.NormalVector))
     {
         throw new ArgumentException("Projection error: view direction is parallel to projection plane!");
     }
     return(new Edge
     {
         startPoint = this.startPoint.ProjectParallelOn(plane, viewDirection),
         endPoint = this.endPoint.ProjectParallelOn(plane, viewDirection)
     });
 }
Example #4
0
        public Arc(Point center, Vector3d startVector, Vector3d endVector, Vector3d normalVector)
        {
            this.point_0    = center;
            this.point_1    = center + startVector.ToPoint();
            this.vector3d_0 = normalVector;
            double num = Vector3d.OrientedAngle(startVector, endVector, normalVector);

            this.double_0 = num;
            if (!Global.AlmostEquals(startVector.Norm, endVector.Norm))
            {
                throw new ArgumentException("Error constructing arc: start vector length not equal end vector length.");
            }
            if (!startVector.IsOrthogonalTo(normalVector) && !endVector.IsOrthogonalTo(normalVector))
            {
                throw new ArgumentException("Error constructing arc: Normal vector not orthogonal to start and end vector.");
            }
        }
Example #5
0
        public Line ProjectParallelOn(Plane plane, Vector3d viewDirection)
        {
            if (viewDirection.IsOrthogonalTo(plane.NormalVector))
            {
                throw new ArgumentException("Projection error: view direction is parallel to projection plane!");
            }
            if (viewDirection.IsParallelTo(this.vector3d_0))
            {
                throw new ArgumentException("Projection error: view direction and line are collinear!");
            }
            Point point  = this.point_0.ProjectParallelOn(plane, viewDirection);
            Point point2 = (this.point_0 + this.vector3d_0.ToPoint()).ProjectParallelOn(plane, viewDirection);
            Line  line   = new Line(point, point2);

            line.DirectionVector = line.DirectionVector.Normalize();
            return(line);
        }
Example #6
0
        public static Ellipse ConstructFromConjugateDiameters(Point M, Point P, Point Q)
        {
            Ellipse result;

            try
            {
                if (P.DistanceTo(M) > Q.DistanceTo(M))
                {
                    Point point = P.DeepCopy();
                    P = Q.DeepCopy();
                    Q = point.DeepCopy();
                }
                Vector3d vector3d  = new Vector3d(Q - M);
                Vector3d vector3d2 = new Vector3d(P - M);
                if (vector3d2.IsOrthogonalTo(vector3d))
                {
                    result = new Ellipse(M, vector3d, vector3d2);
                }
                else
                {
                    Plane plane = new Plane(M, P, Q);
                    plane.Normalize();
                    Matrix3d rotationMatrix = Matrix3d.RotationArbitraryAxis(plane.NormalVector, 1.5707963267948966);
                    Point    point2         = P.Rotate(M, rotationMatrix);
                    if (Vector3d.Angle(vector3d, new Vector3d(point2 - M)) > 1.5707963267948966)
                    {
                        point2 = -1.0 * (point2 - M) + M;
                    }
                    Point  midPoint = new Edge(point2, Q).MidPoint;
                    Circle circle   = new Circle(midPoint, M.DistanceTo(midPoint), plane.NormalVector);
                    Plane  plane2   = new Plane(midPoint, new Vector3d(point2 - midPoint), plane.NormalVector);
                    plane2.Normalize();
                    Edge   edge = plane2.method_5(circle);
                    double num  = Q.DistanceTo(edge.StartPoint);
                    double num2 = Q.DistanceTo(edge.EndPoint);
                    if (num < num2)
                    {
                        num  = num2;
                        num2 = Q.DistanceTo(edge.StartPoint);
                    }
                    Vector3d vector3d3 = new Vector3d(edge.EndPoint - M);
                    Vector3d vector3d4 = new Vector3d(edge.StartPoint - M);
                    if (vector3d4.Norm > vector3d3.Norm)
                    {
                        vector3d3 = new Vector3d(edge.StartPoint - M);
                        vector3d4 = new Vector3d(edge.EndPoint - M);
                    }
                    vector3d3.Norm = num;
                    vector3d4.Norm = num2;
                    Ellipse ellipse = new Ellipse();
                    ellipse.point_0 = M;
                    if (vector3d3.Norm >= vector3d4.Norm)
                    {
                        ellipse.vector3d_0 = vector3d3;
                        ellipse.vector3d_1 = vector3d4;
                    }
                    else
                    {
                        ellipse.vector3d_0 = vector3d4;
                        ellipse.vector3d_1 = vector3d3;
                    }
                    result = ellipse;
                }
            }
            catch (System.Exception ex)
            {
                throw new ArithmeticException("Rytz construction failed due to numerical problems:\n" + ex.Message);
            }
            return(result);
        }