Exemplo n.º 1
0
        private void DrawMeridians(List <List <NurbsPoint> > controlNet, decimal[] circleKnotVector)
        {
            var knotU = this.CurveKnotVector;
            var knotV = circleKnotVector;

            controlNet = controlNet.Transpose();

            var stepV = 1M / (controlNet.Count * 10);

            for (var v = 0M; v.LessThanOrEqualTo(1M); v += stepV)
            {
                var curvePoints = new List <Point3D>();

                var stepU = 1M / (controlNet.First().Count * 10);

                for (var u = 0M; u.LessThanOrEqualTo(1M); u += stepU)
                {
                    var point = SpaceLogic.DeBoorSurface(controlNet, u, knotU, v, knotV).ToPoint3D();
                    curvePoints.Add(point);
                    curvePoints.Add(point);
                }

                curvePoints.RemoveAt(curvePoints.Count - 1);
                curvePoints.RemoveAt(0);

                var pts   = new Point3DCollection(curvePoints);
                var curve = new LinesVisual3D {
                    Color = Colors.Blue, Points = pts, Thickness = 1
                };
                this.HelixView.Children.Add(curve);
            }
        }
Exemplo n.º 2
0
        private void Render()
        {
            this.HelixView.Children.Clear();
            var controlNet       = new List <List <NurbsPoint> >();
            var circleKnotVector = new decimal[1];

            foreach (var cp in this.ControlPoints)
            {
                controlNet.Add(SpaceLogic.Arc(cp, this.Angle, out circleKnotVector));
            }

            if (this.MenuItemAxis.IsChecked)
            {
                var axis = new LinesVisual3D
                {
                    Color  = Colors.Red,
                    Points = new Point3DCollection(new List <Point3D>
                    {
                        new Point3D(0, -1000d, 0),
                        new Point3D(0, 1000d, 0)
                    }),
                    Thickness = 1
                };
                this.HelixView.Children.Add(axis);
            }

            if (this.MenuItemNet.IsChecked)
            {
                this.DrawControlNet(controlNet);
            }

            if (this.MenuItemCurve.IsChecked)
            {
                var points =
                    new Point3DCollection(NurbsLogic.GetCurvePoints(this.Degree, this.ControlPoints, CurveKnotVector));
                var curve = new LinesVisual3D {
                    Color = Colors.BlueViolet, Points = points, Thickness = 1
                };
                this.HelixView.Children.Add(curve);
            }

            if (this.MenuItemPar.IsChecked)
            {
                this.DrawParallels(controlNet, circleKnotVector);
            }

            if (this.MenuItemMer.IsChecked)
            {
                this.DrawMeridians(controlNet, circleKnotVector);
            }
        }
Exemplo n.º 3
0
        public static List <NurbsPoint> Arc(NurbsPoint P0, int phi, out decimal[] knotVector)
        {
            var arcs = 0;

            knotVector = new decimal[] { };

            if (phi <= 90)
            {
                arcs       = 1;
                knotVector = new[] { 0M, 0, 0, 1, 1, 1 };
            }
            else if (phi <= 180)
            {
                arcs       = 2;
                knotVector = new[] { 0, 0, 0, 1M / 2, 1M / 2, 1, 1, 1 };
            }
            else if (phi <= 270)
            {
                arcs       = 3;
                knotVector = new[] { 0, 0, 0, 1M / 3, 1M / 3, 2M / 3, 2M / 3, 1, 1, 1 };
            }
            else if (phi <= 360)
            {
                arcs       = 4;
                knotVector = new[] { 0, 0, 0, 1M / 4, 1M / 4, 2M / 4, 2M / 4, 3M / 4, 3M / 4, 1, 1, 1 };
            }

            var theta      = phi / (double)arcs;
            var pointsList = new List <NurbsPoint> {
                P0
            };

            if (arcs >= 1)
            {
                var P1 = SpaceLogic.MiddlePoint(pointsList.LastOrDefault(), theta);
                var P2 = SpaceLogic.RotateY(pointsList.LastOrDefault(), theta);
                pointsList.Add(P1);
                pointsList.Add(P2);
            }

            if (arcs >= 2)
            {
                var P3 = SpaceLogic.MiddlePoint(pointsList.LastOrDefault(), theta);
                var P4 = SpaceLogic.RotateY(pointsList.LastOrDefault(), theta);
                pointsList.Add(P3);
                pointsList.Add(P4);
            }

            if (arcs >= 3)
            {
                var P5 = SpaceLogic.MiddlePoint(pointsList.LastOrDefault(), theta);
                var P6 = SpaceLogic.RotateY(pointsList.LastOrDefault(), theta);
                pointsList.Add(P5);
                pointsList.Add(P6);
            }

            if (arcs >= 4)
            {
                var P7 = SpaceLogic.MiddlePoint(pointsList.LastOrDefault(), theta);
                var P8 = SpaceLogic.RotateY(pointsList.LastOrDefault(), theta);
                pointsList.Add(P7);
                pointsList.Add(P8);
            }

            return(pointsList);
        }