示例#1
0
文件: KDTree.cs 项目: Arnyev/MG
        private bool CheckIntersection(List <Vector4> points, List <Intersection> intersections, Triangle triangleB, Vector3 p1, Vector3 p2,
                                       TriangleIndices triIndices, Vector2 myParameterP1, Vector2 myParameterP2, TriangleParameters otherParameter)
        {
            if (!IntersectionCurve.CheckIntersection(triangleB.A, triangleB.B, triangleB.C, p1, p2 - p1, out var id))
            {
                return(false);
            }

            var myParams    = myParameterP1 * (1 - id.D) + myParameterP2 * id.D;
            var otherParams = otherParameter.P1 * id.P1 + otherParameter.P2 * id.P2 +
                              otherParameter.P3 * id.P3;

            var worldPoint = new Vector4(p1 * (1 - id.D) + p2 * id.D, 1);

            points.Add(worldPoint);
            intersections.Add(new Intersection(myParams, otherParams));

            return(true);
        }
示例#2
0
        public void DrawCurveParams()
        {
            var intersectingCurves = _listBox.Items.OfType <IntersectionCurve>().Where(x => x.Selected).ToList();

            if (intersectingCurves.Count != 1)
            {
                return;
            }

            var curve = intersectingCurves[0];

            var size = 500;

            List <Vector2> paramsA = new List <Vector2>();

            curve.GetPoints(out paramsA);
            var nc = new IntersectionCurve(curve.B, curve.A, _cursor);

            List <Vector2> paramsB = new List <Vector2>();

            nc.GetPoints(out paramsB);

            var bitmap1 = new DirectBitmap(size, size);
            var bitmap2 = new DirectBitmap(size, size);

            var form = new Form()
            {
                Size = new Size(2 * size + 50, size + 50)
            };

            form.Controls.Add(new PictureBox {
                Size = new Size(size, size), Image = bitmap1.Bitmap
            });
            form.Controls.Add(new PictureBox {
                Size = new Size(size, size), Location = new Point(size, 0), Image = bitmap2.Bitmap
            });

            curve.A.DrawCurve(paramsA, bitmap1);
            curve.B.DrawCurve(paramsB, bitmap2);

            form.ShowDialog();
        }