Exemplo n.º 1
0
        public Satellite3D()
        {
            orbit = new TubeVisual3D() { Diameter = 0.3, ThetaDiv = 12 };
            orbit.Material = MaterialHelper.CreateMaterial(null, Brushes.Gray, Brushes.White, 0.5, 40);

            Children.Add(orbit);
        }
Exemplo n.º 2
0
/*        internal void drawLine(Point3D start, Point3D pt, bool hit)
 *      {
 *          TubeVisual3D line;
 *          lines.TryGetValue(start, out line);
 *
 *          if (line != null)
 *          {
 *              this.Children.Remove(line);
 *              lines.Remove(start);
 *          }
 *          Point3DCollection contours = new Point3DCollection();
 *          contours.Add(ToWorld(start));
 *          contours.Add(ToWorld(pt));
 *          line = new TubeVisual3D { Diameter = 0.5, Path = contours, Fill = Brushes.SandyBrown };
 *          lines.Add(start,line);
 *          this.Children.Add(line);
 *
 *          addBox(start);
 *          if(hit) addBox(pt);
 *      }
 */
        internal void drawLine(Point3D start, Point3D end)
        {
            TubeVisual3D line;

            lines.TryGetValue(start, out line);

            if (line != null)
            {
                this.Children.Remove(line);
                lines.Remove(start);
            }
            Point3DCollection contours = new Point3DCollection();

            contours.Add(ToWorld(start));
            contours.Add(ToWorld(end));
            line = new TubeVisual3D {
                Diameter = 0.3, Path = contours, Fill = Brushes.DarkOliveGreen
            };
            lines.Add(start, line);
            this.Children.Add(line);

            string x = string.Format("{0:0.00}", end.X);
            string y = string.Format("{0:0.00}", end.Y);
            string z = string.Format("{0:0.00}", end.Z);

            string text = x + "," + y + "," + z;

            addBox(start);
            addBox(end);
            add3DText(end, text);
        }
Exemplo n.º 3
0
        public void CreateTube(Point3DCollection path)
        {
            double diameter = 0;

            if (Units == true)  //Metric
            {
                diameter = 25.4 * 0.125;
                //Update camera position so it is zoomed in enough to see
                camera.Position      = new Point3D(100, 50, 200);
                camera.LookDirection = new Vector3D(-100, 0, -100);
                camera.UpDirection   = new Vector3D(0, 1, 0);
                camera.FieldOfView   = 60;
            }

            if (Units == false) //Inches
            {
                diameter = 0.125;
                //Update camera position so it is zoomed in enough to see
                camera.Position      = new Point3D(10, 5, 20);
                camera.LookDirection = new Vector3D(-10, 0, -10);
                camera.UpDirection   = new Vector3D(0, 1, 0);
                camera.FieldOfView   = 60;
            }

            var tube = new TubeVisual3D();

            tube.Path         = path;
            tube.Diameter     = diameter;
            tube.IsPathClosed = false;
            tube.Fill         = Brushes.Gray;

            hVp3D.Children.Add(tube);
        }
Exemplo n.º 4
0
        private void LoadUnitModel()
        {
            CreateLotModel();
            CreateUnitModel();

            UnitFileEntry.UnitEffects.ForEach(e => viewPort.Children.Add(e.CreateGeometry()));
            UnitFileEntry.UnitLights.ForEach(l => viewPort.Children.Add(l.CreateGeometry()));
            UnitFileEntry.UnitPathPoints.ForEach(l => viewPort.Children.Add(l.CreateGeometry()));
            UnitFileEntry.UnitSimsSpawners.ForEach(l => viewPort.Children.Add(l.CreateGeometry()));
            UnitFileEntry.UnitBinDrawSlots.ToList().ForEach(l => l.ForEach(b => viewPort.Children.Add(b.CreateGeometry())));
            UnitFileEntry.UnitBinDecals.ToList().ForEach(l => l.ForEach(b => viewPort.Children.Add(b.CreateGeometry())));
            //create the paths
            int i = 0;

            if (UnitFileEntry.UnitPaths.Count > 0)
            {
                foreach (UnitPath path in UnitFileEntry.UnitPaths)
                {
                    int startIndex = UnitFileEntry.UnitPath[i * 2].Value;
                    int endIndex   = UnitFileEntry.UnitPath[(i * 2) + 1].Value;

                    TubeVisual3D visual = new TubeVisual3D();
                    visual.Material = MaterialHelper.CreateMaterial(Colors.Aqua);

                    foreach (UnitPathPoint point in UnitFileEntry.UnitPathPoints.Where(p => p.Index.Value <= endIndex && p.Index.Value >= startIndex))
                    {
                        visual.Path.Add(new Point3D(point.Point.X, point.Point.Y, point.Point.Z));
                    }

                    viewPort.Children.Add(visual);

                    i++;
                }
            }
        }
        private TubeVisual3D GetPathForMeanReadingLocation(double maxHeight)
        {
            int    totalDeltas = BooksReadProvider.BookLocationDeltas.Count;
            double increment   = maxHeight / (0.5 * (1 + totalDeltas));

            List <Point3D> averagePosition = new List <Point3D>();
            int            counter         = 0;

            foreach (BookLocationDelta delta in BooksReadProvider.BookLocationDeltas)
            {
                PolygonPoint latLong = new PolygonPoint {
                    Latitude = delta.AverageLatitude, Longitude = delta.AverageLongitude
                };
                double x, y;
                latLong.GetCoordinates(out x, out y);

                double height = maxHeight - (counter * increment);

                averagePosition.Add(new Point3D(x, y, height));
                counter++;
            }

            TubeVisual3D path = new TubeVisual3D
            {
                Path         = new Point3DCollection(averagePosition),
                Diameter     = 0.5,
                ThetaDiv     = 20,
                IsPathClosed = false,
                Fill         = Brushes.Green
            };

            return(path);
        }
Exemplo n.º 6
0
        public static void drawSnakes(ModelVisual3D container)
        {
            container.Children.Clear();
            TubeVisual3D snake = new TubeVisual3D {
                Diameter = 2.00, Path = snakes, Fill = Brushes.LightGoldenrodYellow
            };

            container.Children.Add(snake);
        }
Exemplo n.º 7
0
 public Component()
 {
     Tube      = new TubeVisual3D();
     Tube.Path = new Point3DCollection();
     Tube.Path.Add(new Point3D(-15, 0, 0));
     Tube.Path.Add(new Point3D(15, 0, 0));
     Tube.Diameter     = TubeDiameter;
     Tube.Fill         = new SolidColorBrush(Color.FromRgb((byte)(r.Next(0, 255)), (byte)(r.Next(0, 255)), (byte)(r.Next(0, 255))));
     Tube.IsPathClosed = false;
 }
Exemplo n.º 8
0
        public Satellite3D()
        {
            orbit = new TubeVisual3D()
            {
                Diameter = 0.3, ThetaDiv = 12
            };
            orbit.Material = MaterialHelper.CreateMaterial(null, Brushes.Gray, Brushes.White, 0.5, 40);

            Children.Add(orbit);
        }
Exemplo n.º 9
0
        public Planet3D()
        {
            Satellites = new List <Satellite3D>();

            orbit = new TubeVisual3D()
            {
                Diameter = 0.8, ThetaDiv = 16
            };
            orbit.Material = MaterialHelper.CreateMaterial(null, Brushes.Blue, Brushes.Gray, 0.5, 20);
            Children.Add(orbit);
        }
Exemplo n.º 10
0
        static TubeVisual3D MakeTubeForPositions(PXCMPoint3DF32 p1, PXCMPoint3DF32 p2)
        {
            var tube = new TubeVisual3D();

            tube.Diameter = Constants.TubeDiameter;
            Point3DCollection points = new Point3DCollection();

            points.Add(new Point3D(p1.x, p1.y, p1.z));
            points.Add(new Point3D(p2.x, p2.y, p2.z));
            tube.Path = points;
            tube.Fill = Brushes.Silver;
            return(tube);
        }
Exemplo n.º 11
0
        void contours(Brush b)
        {
            model        = new Wire();
            model.Brace1 = brace1.Model;
            model.Brace2 = brace2.Model;

            Point3D c1 = brace1.centroid();
            Point3D c2 = brace2.centroid();

            /*
             * int n = 6;
             * // Create the data to be fitted
             * float[] x = new float[n];
             * float[] y = new float[n];
             * Random rand = new Random(1);
             * float xf = (float)(c2.X - c1.X)/n;
             * float yf = (float)(c2.Y - c1.Y) / n;
             * for (int i = 0; i < n; i++)
             * {
             *  x[i] = (float) c1.X + (i * xf);
             *  y[i] = (float) c1.Y + (i * yf);
             * }
             * int upsampleFactor = 10;
             * int nInterpolated = n * upsampleFactor;
             * float[] xs = new float[nInterpolated];
             *
             * for (int i = 0; i < nInterpolated; i++)
             * {
             *  xs[i] = (float)i * (n - 1) / (float)(nInterpolated - 1);
             * }
             * CubicSpline spline = new CubicSpline();
             * float[] ys = spline.FitAndEval(x, y, xs, true);
             */
            Point3DCollection contours = new Point3DCollection();

            contours.Add(brace1.ToWorld(c1));

            /*for (int i = 0; i < xs.Length; i++)
             * {
             *  contours.Add(new Point3D(xs[i], ys[i], c1.Z));
             * }*/
            contours.Add(brace2.ToWorld(c2));

            this.Children.Clear();

            TubeVisual3D tube = new TubeVisual3D {
                Diameter = 1.02, Path = contours, Fill = b
            };

            this.Children.Add(tube);
        }
Exemplo n.º 12
0
        private void DrawLine3D(Point3D p0, Point3D p1, HelixToolkit.Wpf.HelixViewport3D viewport)
        {
            double tubeDiameter = 0.1;

            TubeVisual3D tube = new TubeVisual3D();

            tube.Path = new Point3DCollection();
            tube.Path.Add(p0);
            tube.Path.Add(p1);
            tube.Diameter     = tubeDiameter;
            tube.Fill         = Brushes.Black;
            tube.IsPathClosed = true;

            viewport.Children.Add(tube);
        }
Exemplo n.º 13
0
        public Element()
        {
            Tube      = new TubeVisual3D();
            Tube.Path = new Point3DCollection();
            Tube.Path.Add(new Point3D(-15, 0, 0));
            Tube.Path.Add(new Point3D(15, 0, 0));
            Tube.Diameter        = tubeDiameter;
            Tube.IsSectionClosed = true;
            Tube.Fill            = new SolidColorBrush(Colors.Silver);
            Tube.IsPathClosed    = false;

            Sphere = new CubeVisual3D();
            //Sphere.Center = new Point3D(15, 0, 0);
            Sphere.Fill       = new SolidColorBrush(Colors.Silver);
            Sphere.SideLength = 0.75;
        }
Exemplo n.º 14
0
        public void drawBorderEdges(MeshGeometry3D mesh)
        {
            Int32Collection   edges = MeshGeometryHelper.FindBorderEdges(mesh);
            Point3DCollection pos   = mesh.Positions;

            for (int i = 1; i < edges.Count; i += 2)
            {
                Point3DCollection paths = new Point3DCollection();
                paths.Add(pos[edges[i - 1]]);
                paths.Add(pos[edges[i]]);
                TubeVisual3D t = new TubeVisual3D {
                    Diameter = 0.02, Path = paths, Fill = Brushes.Yellow
                };
                //t.Transform = new TranslateTransform3D(1, 1, 1);
                this.Children.Add(t);
            }
        }
Exemplo n.º 15
0
        private TubeVisual3D GenerateTube()
        {
            int    n = 180;
            double r = Math.Sqrt(3) / 3;

            Ring1 = this.CreatePath(0, Math.PI * 2, n, u => Math.Cos(u), u => Math.Sin(u) + r, u => Math.Cos(3 * u) / 3);

            TubeVisual3D tube1 = new TubeVisual3D()
            {
                Path         = Ring1,
                Diameter     = 0.5,
                ThetaDiv     = 20,
                IsPathClosed = true,
                Fill         = Brushes.Green
                               //Fill = new Brush() { Colors.Blue}
            };

            return(tube1);
        }
Exemplo n.º 16
0
        public void Initialize()
        {
            wheels = new SphereVisual3D[4];
            offsetXRotationAxis = new Vector3D(0.0, 1.0, 0.0);
            offsetYRotationAxis = new Vector3D(-1.0, 0.0, 0.0);

            PlatformSize        = DefaultPlatformSize;
            Model               = new ModelVisual3D();
            platform            = new CubeVisual3D();
            platform.Fill       = Brushes.Purple;
            platform.SideLength = PlatformSize;
            var platformTransformGroup = new Transform3DGroup();

            platformTransformGroup.Children.Add(new ScaleTransform3D(new Vector3D(1.0, 1.0, platformHeightFactor)));
            platformTransformGroup.Children.Add(new TranslateTransform3D(0.0, 0.0,
                                                                         wheelRadius * 2 + PlatformSize * platformHeightFactor / 2));
            platform.Transform = platformTransformGroup;
            Model.Children.Add(platform);
            for (int i = 0; i < 4; i++)
            {
                var wheel = new SphereVisual3D();
                wheel.Radius   = wheelRadius;
                wheel.Material = Materials.Blue;
                var wheelPosition       = PlatformSize / 2 - wheelRadius;
                var wheelTransformGroup = new Transform3DGroup();
                wheelTransformGroup.Children.Add(new TranslateTransform3D(-wheelPosition * (i % 2 * 2 - 1),
                                                                          wheelPosition * (i % 2 * 2 - 1) * (i >= 2 ? 1.0 : -1.0), 0.5));
                wheel.Transform = wheelTransformGroup;
                Model.Children.Add(wheel);
                wheels[i] = wheel;
            }
            rim           = new TubeVisual3D();
            rim.Fill      = Brushes.White;
            rim.Diameters = new DoubleCollection {
                1.5, 0.0
            };
            rim.Path = new Point3DCollection {
                new Point3D(0, 0, 1.5), new Point3D(0, 0, 1.75)
            };
            Model.Children.Add(rim);
        }
        private void SetupBooksReadByCountryModel()
        {
            Model3DGroup modelGroup = new Model3DGroup();

            // get the range of colours for the for the countries
            int range = _mainModel.AuthorCountries.Count > 0 ?
                        _mainModel.AuthorCountries.Select(s => s.TotalBooksReadFromCountry).Max() : 5;
            OxyPalette      faintPalette;
            List <OxyColor> colors;

            OxyPlotUtilities.SetupFaintPaletteForRange(range, out colors, out faintPalette, 128);

            List <OxyColor> stdColors      = OxyPlotUtilities.SetupStandardColourSet();
            int             geographyIndex = 0;

            foreach (var authorCountry in _mainModel.AuthorCountries.OrderByDescending(x => x.TotalBooksReadFromCountry))
            {
                var name    = authorCountry.Country;
                var country = _mainModel.WorldCountries.Where(w => w.Country == name).FirstOrDefault();
                if (country != null)
                {
                    AddCountryBooksEllipsoid(modelGroup, colors, authorCountry, name, country);
                }

                if (_mainModel.CountryGeographies != null && _mainModel.CountryGeographies.Count > 0)
                {
                    geographyIndex = AddCountryGeographyPlane(modelGroup, stdColors, geographyIndex, name);
                }
            }

            AddGeographiesForCountriesWithoutBooksRead(modelGroup);

            double       maxHeight = Math.Log(range);
            TubeVisual3D path      = GetPathForMeanReadingLocation(maxHeight);

            modelGroup.Children.Add(path.Content);

            BooksReadByCountryModel = modelGroup;
        }
        public override void SetupModel()
        {
            Model3DGroup modelGroup = new Model3DGroup();

            // get the range of colours for the for the countries
            int range = BooksReadProvider.AuthorCountries.Count > 0 ?
                        BooksReadProvider.AuthorCountries.Select(s => s.TotalBooksReadFromCountry).Max() : 5;
            List <Color> colors;

            ColorUtilities.SetupFaintPaletteForRange(range, out colors, 128);
            List <Color> stdColors = ColorUtilities.SetupStandardColourSet();

            int geographyIndex = 0;

            foreach (AuthorCountry authorCountry in BooksReadProvider.AuthorCountries.OrderByDescending(x => x.TotalBooksReadFromCountry))
            {
                string       name    = authorCountry.Country;
                WorldCountry country = GeographyProvider.WorldCountries.FirstOrDefault(w => w.Country == name);
                if (country != null)
                {
                    DiagramUtilities.AddCountryBooksEllipsoid(modelGroup, colors, authorCountry, name, country);
                }

                if (GeographyProvider.CountryGeographies != null && GeographyProvider.CountryGeographies.Count > 0)
                {
                    geographyIndex = AddCountryGeographyPlane(modelGroup, stdColors, geographyIndex, name);
                }
            }

            AddGeographiesForCountriesWithoutBooksRead(modelGroup);

            double       maxHeight = Math.Log(range);
            TubeVisual3D path      = GetPathForMeanReadingLocation(maxHeight);

            modelGroup.Children.Add(path.Content);

            BooksReadByCountryModel = modelGroup;
        }
Exemplo n.º 19
0
        public JawVisual3D(Point3D p1, Point3D p2)
        {
            LineGeometry myLineGeometry = new LineGeometry();
            var          tube           = new TubeVisual3D();

            tube.Material = Materials.Blue;
            tube.Fill     = new SolidColorBrush(Color.FromArgb(80, 0, 0, 0));
            Children.Add(tube);
            Children.Add(new SphereVisual3D()
            {
                Center = p1, Radius = 0.07, Material = Materials.Red
            });
            Children.Add(new SphereVisual3D()
            {
                Center = p2, Radius = 0.07, Material = Materials.Green
            });


            //Point3DCollection pts = new Point3DCollection();


            //pts.Add(p1);
            //pts.Add(p2);

            //LinesVisual3D ln = new LinesVisual3D();
            //ln.Points = pts;
            //ln.Color = Colors.Black;
            //Children.Add(ln);

            //added by achie
            CruisingSpeed = DefaultCruisingSpeed;
            double cruisingRadius = EarthRadius + DefaultCruisingAltitude;
            double takeoffLength  = DefaultTakeoffLength;
            double groundRadius   = EarthRadius;

            var o  = new Point3D(0, 0, 0);
            var v1 = p1 - o;
            var v2 = p2 - o;
            var z  = Vector3D.CrossProduct(v1, v2);
            var x  = v1;
            var y  = Vector3D.CrossProduct(x, z);

            x.Normalize();
            y.Normalize();
            double v2X = Vector3D.DotProduct(v2, x);
            double v2Y = Vector3D.DotProduct(v2, y);
            double v2A = Math.Atan2(v2Y, v2X);

            const int n = 100;

            var pts = new Point3DCollection();

            double da = v2A / (n - 1);

            double distance      = cruisingRadius * Math.Abs(v2A);
            double landingLength = takeoffLength;

            double l = 0;

            for (int i = 0; i < n; i++)
            {
                double   a = i * da;
                Vector3D v = x * Math.Cos(a) + y * Math.Sin(a);
                double   r = cruisingRadius;

                r = groundRadius + Math.Sin(Math.PI * i / (n - 1)) * (cruisingRadius - groundRadius);

                var p = o + v * r;
                //  Children.Add(new SphereVisual3D() { Center = p, Radius = 60, Material = Materials.Gray});

                pts.Add(p);
                l += Math.Abs(cruisingRadius * da);
            }

            Distance = distance;
        }
Exemplo n.º 20
0
        public MainViewModel(MainWindow mainWindow)
        {
            // TODO: Complete member initialization
            this.mainWindow = mainWindow;

            Model3DGroup modelGroup = new Model3DGroup();

            TubeVisual3D      tube1     = GenerateTube();
            RectangleVisual3D rectangle = GenerateRectangle();
            SphereVisual3D    sphere    = new SphereVisual3D()
            {
                Center = new Point3D(1.5, 2.5, -0.7), Radius = 2
            };

            //modelGroup.Children.Add(tube1.Model);
            //modelGroup.Children.Add(rectangle.Model);
            //modelGroup.Children.Add(sphere.Model);

            /*
             *
             * Point3D point;
             * Point3D point2;
             * Point3D point3;
             * Point3D point4;
             * AddElementsPart2(modelGroup, out point, out point2, out point3, out point4);
             *
             *
             * TubeVisual3D path = new TubeVisual3D()
             * {
             *  Path =  new Point3DCollection(new List<Point3D>(){
             *  point + new Vector3D(0, 0, 20),
             *  point2 + new Vector3D(0, 0, 19),
             *  point3 + new Vector3D(0, 0, 18),
             *  point4 + new Vector3D(0, 0, 17)
             *  }),
             *  Diameter = 0.5,
             *  ThetaDiv = 20,
             *  IsPathClosed = false,
             *  Fill = Brushes.Green
             *  //Fill = new Brush() { Colors.Blue}
             * };
             *
             * modelGroup.Children.Add(path.Content);
             *
             */
            //AddSolidBox(modelGroup);

            //AddRevolved(modelGroup);



            HelixVisual3D helixItem = new HelixVisual3D();

            helixItem.Fill     = new SolidColorBrush(Colors.Violet);
            helixItem.Origin   = new Point3D(0, 0, -0.45);
            helixItem.Diameter = 0.1;
            helixItem.Turns    = 2;
            helixItem.Length   = 0.9;
            helixItem.Radius   = 0.35;

            //modelGroup.Children.Add(helixItem.Content);
            //modelGroup.Children.Add(box.Content);


            //<helix:HelixVisual3D
            //Origin="0 0 -0.45"
            //Diameter="0.1"
            //Turns="2"
            //Length="0.9"
            //Radius="0.35"
            //Fill="Violet"
            //Visible="{Binding IsChecked, ElementName=HelixVisible}"/>


            numberOfPoints = 100;

            // wireLines = new WireLines { Color = Colors.Black, Thickness = 3,  };
            Points = new Point3DCollection(GeneratePoints(numberOfPoints, 7000 * 0.001));
            //wireLines.Lines = Points;


            //modelGroup.Children.Add(wireLines.Content);


            var y0          = 0d;
            var theta       = Math.PI / 180 * 30;
            var roofBuilder = new MeshBuilder(false, false);
            var y1          = y0 + Math.Tan(theta) * 5 / 2;
            var p0          = new Point(0, y1);
            var p1          = new Point(5 / 2 + 0.2 * Math.Cos(theta), y0 - 0.2 * Math.Sin(theta));
            var p2          = new Point(p1.X + 0.1 * Math.Sin(theta), p1.Y + 0.1 * Math.Cos(theta));
            var p3          = new Point(0, y1 + 0.1 / Math.Cos(theta));
            var p4          = new Point(-p2.X, p2.Y);
            var p5          = new Point(-p1.X, p1.Y);


            IList <Point> roofSection = new List <Point>()
            {
                p0, p1, p1, p2, p2, p3, p3, p4, p4, p5, p5, p0
            };
            var roofAxisX  = new Vector3D(0, -1, 0);
            var roofAxisY  = new Vector3D(0, 0, 1);
            var roofOrigin = new Point3D(1, 1, 1);
            //roofBuilder.AddPolygon(roofSection, roofAxisX, roofAxisY, roofOrigin);


            Point3DCollection simplePoly = new System.Windows.Media.Media3D.Point3DCollection(
                new List <Point3D>()
            {
                new Point3D(1, 0, 1),
                new Point3D(1, 1, 1),
                new Point3D(0, 1, 1),
                new Point3D(0, 0, 1),

                /*
                 * //new Point3D(1,0, 1),
                 * new Point3D(0,0, -1),
                 * new Point3D(1,0, -1),
                 * new Point3D(1,1, -1),
                 * new Point3D(0,1, -1),
                 * //new Point3D(1,0, 1),
                 * new Point3D(0,0, -1),
                 * new Point3D(0,0, 1),
                 */
            }
                );


            roofBuilder.AddPolygon(simplePoly);

            //roofBuilder.AddRectangularMesh()

            GeometryModel3D roofGeometry = new GeometryModel3D();

            //var material = MaterialHelper.CreateMaterial(Brushes.LightBlue, ambient: 77, freeze: false);
            var material = MaterialHelper.CreateMaterial(Colors.LawnGreen, 0.25);


            roofGeometry.Material     = material;
            roofGeometry.BackMaterial = material;

            roofGeometry.Geometry = roofBuilder.ToMesh(true);
            modelGroup.Children.Add(roofGeometry);



            //ScreenSpaceLines3D Wireframe = new ScreenSpaceLines3D();

            //Wireframe.Thickness = 2;
            //Wireframe.Color = Colors.Black;
            //Wireframe.Points = simplePoly;
            ////Wireframe.MakeWireframe(roofGeometry);
            //modelGroup.Children.Add(Wireframe.Content);



            var Mesh = new MeshGeometry3D();
            //var Material = MaterialHelper.CreateImageMaterial(image);
            var Damping    = 0.98;
            var integrator = new VerletIntegrator()
            {
                Iterations = 4, Damping = 0.98
            };
            var WindSpeed     = 6;
            var WindDirection = 180;
            var PoleHeight    = 12;
            var Height        = 3;
            var Length        = 4;
            var Mass          = 0.8;
            var m             = 48;
            var n             = 32;

            var pts = new Point3D[n, m];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    pts[i, j] = new Point3D(-Length * j / (m - 1), 0, PoleHeight - Height * i / (n - 1));
                }
            }


            var pts2 = new Point3D[2, 4];

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    double x = 0, z = 0;
                    if (i == 0)
                    {
                        x = 0; z = 0;
                    }
                    if (i == 1)
                    {
                        x = 1; z = 0;
                    }
                    if (i == 2)
                    {
                        x = 1; z = 1;
                    }
                    if (i == 3)
                    {
                        x = 0; z = 1;
                    }

                    pts[i, j] = new Point3D(x, i, PoleHeight - z);
                }
            }


            var mb = new MeshBuilder(false, true);

            //mb.AddRectangularMesh(pts, null, false, false);
            mb.AddRectangularMesh(pts, null, false, false);
            Mesh = mb.ToMesh();

            var gradientMaterial = CreateGradientBrushMaterial();


            gradientMaterial = MaterialHelper.CreateMaterial(Colors.LightBlue, 0.25);


            GeometryModel3D meshGeometry = new GeometryModel3D();

            meshGeometry.Geometry     = Mesh;
            meshGeometry.Material     = gradientMaterial;
            meshGeometry.BackMaterial = gradientMaterial;
            modelGroup.Children.Add(meshGeometry);


            this.Model = modelGroup;
        }
Exemplo n.º 21
0
        public static double EarthRadius = 6371; // km

        #endregion Fields

        #region Constructors

        public FlightVisual3D(Point3D p1, Point3D p2)
        {
            var tube = new TubeVisual3D();
            // tube.Material = MaterialHelper.CreateMaterial(Color.FromArgb(80, 255, 255, 255)); // Materials.Yellow;
            tube.Fill = new SolidColorBrush(Color.FromArgb(80, 255, 255, 255));
            Children.Add(tube);
            Children.Add(new SphereVisual3D() { Center = p1, Radius = 100, Material = Materials.Green });
            Children.Add(new SphereVisual3D() { Center = p2, Radius = 100, Material = Materials.Red });

            double lat1, lon1, lat2, lon2;
            PointToLatLon(p1, out lat1, out lon1);
            PointToLatLon(p2, out lat2, out lon2);
            From = String.Format("{0:0.00} {1:0.00}", lat1, lon1);
            To = String.Format("{0:0.00} {1:0.00}", lat2, lon2);

            CruisingSpeed = DefaultCruisingSpeed;
            double cruisingRadius = EarthRadius + DefaultCruisingAltitude;
            double takeoffLength = DefaultTakeoffLength;
            double groundRadius = EarthRadius;
            const double tubeDiameter = 60;

            var o = new Point3D(0, 0, 0);
            var v1 = p1 - o;
            var v2 = p2 - o;
            var z = Vector3D.CrossProduct(v1, v2);
            var x = v1;
            var y = Vector3D.CrossProduct(x, z);
            x.Normalize();
            y.Normalize();
            double v2X = Vector3D.DotProduct(v2, x);
            double v2Y = Vector3D.DotProduct(v2, y);
            double v2A = Math.Atan2(v2Y, v2X);

            const int n = 100;

            var pts = new Point3DCollection();

            double da = v2A / (n - 1);

            double distance = cruisingRadius * Math.Abs(v2A);
            double landingLength = takeoffLength;

            double l = 0;
            for (int i = 0; i < n; i++)
            {
                double a = i * da;
                Vector3D v = x * Math.Cos(a) + y * Math.Sin(a);
                double r = cruisingRadius;

                //if (l < takeoffLength)
                //{
                //    r = groundRadius + Math.Sin(Math.PI/2*l/takeoffLength)*(cruisingRadius - groundRadius);
                //}
                //if (l > distance - landingLength)
                //{
                //    r = groundRadius + Math.Sin(Math.PI/2*(distance - l)/takeoffLength)*(cruisingRadius - groundRadius);
                //}

                r = groundRadius + Math.Sin(Math.PI * i / (n - 1)) * (cruisingRadius - groundRadius);

                var p = o + v * r;
                //  Children.Add(new SphereVisual3D() { Center = p, Radius = 60, Material = Materials.Gray});

                pts.Add(p);
                l += Math.Abs(cruisingRadius * da);
            }
            tube.Diameter = tubeDiameter;
            tube.ThetaDiv = 16;
            tube.Path = pts;
            Distance = distance;
        }
Exemplo n.º 22
0
        public FlightVisual3D(Point3D p1, Point3D p2)
        {
            var tube = new TubeVisual3D();

            tube.Material = MaterialHelper.CreateMaterial(Color.FromArgb(80, 255, 255, 255)); // Materials.Yellow;
            Children.Add(tube);
            Children.Add(new SphereVisual3D()
            {
                Center = p1, Radius = 100, Material = Materials.Green
            });
            Children.Add(new SphereVisual3D()
            {
                Center = p2, Radius = 100, Material = Materials.Red
            });

            double lat1, lon1, lat2, lon2;

            PointToLatLon(p1, out lat1, out lon1);
            PointToLatLon(p2, out lat2, out lon2);
            From = String.Format("{0:0.00} {1:0.00}", lat1, lon1);
            To   = String.Format("{0:0.00} {1:0.00}", lat2, lon2);

            CruisingSpeed = DefaultCruisingSpeed;
            double       cruisingRadius = EarthRadius + DefaultCruisingAltitude;
            double       takeoffLength  = DefaultTakeoffLength;
            double       groundRadius   = EarthRadius;
            const double tubeDiameter   = 60;

            var o  = new Point3D(0, 0, 0);
            var v1 = p1 - o;
            var v2 = p2 - o;
            var z  = Vector3D.CrossProduct(v1, v2);
            var x  = v1;
            var y  = Vector3D.CrossProduct(x, z);

            x.Normalize();
            y.Normalize();
            double v2X = Vector3D.DotProduct(v2, x);
            double v2Y = Vector3D.DotProduct(v2, y);
            double v2A = Math.Atan2(v2Y, v2X);

            const int n = 100;

            var pts = new Point3DCollection();

            double da = v2A / (n - 1);

            double distance      = cruisingRadius * Math.Abs(v2A);
            double landingLength = takeoffLength;

            double l = 0;

            for (int i = 0; i < n; i++)
            {
                double   a = i * da;
                Vector3D v = x * Math.Cos(a) + y * Math.Sin(a);
                double   r = cruisingRadius;

                //if (l < takeoffLength)
                //{
                //    r = groundRadius + Math.Sin(Math.PI/2*l/takeoffLength)*(cruisingRadius - groundRadius);
                //}
                //if (l > distance - landingLength)
                //{
                //    r = groundRadius + Math.Sin(Math.PI/2*(distance - l)/takeoffLength)*(cruisingRadius - groundRadius);
                //}

                r = groundRadius + Math.Sin(Math.PI * i / (n - 1)) * (cruisingRadius - groundRadius);

                var p = o + v * r;
                //  Children.Add(new SphereVisual3D() { Center = p, Radius = 60, Material = Materials.Gray});

                pts.Add(p);
                l += Math.Abs(cruisingRadius * da);
            }
            tube.Diameter = tubeDiameter;
            tube.ThetaDiv = 16;
            tube.Path     = pts;
            Distance      = distance;
        }