コード例 #1
0
        private void DefineModel(Model3DGroup model_group)
        {
            #region Clear the scene
            MainModel3Dgroup.Children.Clear();
            DefineLights();
            #endregion

            GetAlpha();
            GetGammas();

            DiffuseMaterial surface_material = new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(120, 255, 128, 0)));

            #region Draw Axes
            model_group.Children.Add(new GeometryModel3D(
                                         new Segment(new Point3D(-1.2, 0, 0), new Point3D(1.2, 0, 0), new Vector3D(0, 0.1, 0)).ToMesh(true),
                                         new DiffuseMaterial(Brushes.Blue))
                                     );

            model_group.Children.Add(new GeometryModel3D(
                                         new Segment(new Point3D(0, 0, -1.2), new Point3D(0, 0, 1.2), new Vector3D(0.1, 0.1, 0.1)).ToMesh(true),
                                         new DiffuseMaterial(Brushes.Green))
                                     );

            model_group.Children.Add(new GeometryModel3D(
                                         new Segment(new Point3D(0, -1.2, 0), new Point3D(0, 1.2, 0), new Vector3D(0.1, 0.1, 0.1)).ToMesh(true),
                                         new DiffuseMaterial(Brushes.Red))
                                     );
            #endregion

            #region Draw Sphere
            if (draw_sphere)
            {
                model_group.Children.Add(new GeometryModel3D(new Sphere(new Point3D(0, 0, 0), 1, 50, 50).ToMesh(), surface_material)
                {
                    BackMaterial = surface_material
                });
            }
            #endregion

            #region Draw First Position
            var computed_position_0 = new Polar(t0, p0).ToPoint3D().Rot(Rotations);
            model_group.Children.Add(new GeometryModel3D(
                                         new Segment(computed_position_0.Scale(0.9), new Point3D(0, 0, 0), new Vector3D(0, 0.1, 0)).ToMesh(true),
                                         new DiffuseMaterial(Brushes.Black))
                                     );
            model_group.Children.Add(new GeometryModel3D(new Sphere(computed_position_0, 0.05, 5, 5).ToMesh(), new DiffuseMaterial(Brushes.Fuchsia)));
            #endregion

            #region Draw Last Position

            var computed_position_1 = new Polar(t1, p1).ToPoint3D().Rot(Rotations);
            model_group.Children.Add(new GeometryModel3D(
                                         new Segment(computed_position_1.Scale(0.9), new Point3D(0, 0, 0), new Vector3D(0, 0.1, 0)).ToMesh(true),
                                         new DiffuseMaterial(Brushes.Black))
                                     );
            model_group.Children.Add(new GeometryModel3D(new Sphere(computed_position_1, 0.05, 5, 5).ToMesh(), new DiffuseMaterial(Brushes.Gainsboro)));
            #endregion

            #region Compute And Draw Trajectory
            Func <double, double> theta = t => gamma0 + t * delta_gamma;
            Func <double, double> phi   = t => 0;
            Trajectory = t => new Point3D(Math.Cos(phi(t)) * Math.Cos(theta(t)), Math.Sin(phi(t)), Math.Cos(phi(t)) * Math.Sin(theta(t))).RotX(alpha).RotZ(p0).RotY(t0).Rot(Rotations);
            model_group.Children.Add(new GeometryModel3D(
                                         new Trajectory(Trajectory, 0, 1).ToMesh(),
                                         new DiffuseMaterial(new SolidColorBrush(Colors.Black))));
            #endregion
        }