当前位置: 首页>>代码示例>>C#>>正文


C# Media3D.Vector3D类代码示例

本文整理汇总了C#中System.Windows.Media.Media3D.Vector3D的典型用法代码示例。如果您正苦于以下问题:C# Vector3D类的具体用法?C# Vector3D怎么用?C# Vector3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Vector3D类属于System.Windows.Media.Media3D命名空间,在下文中一共展示了Vector3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddPlaneToMesh

        public static MeshGeometry3D AddPlaneToMesh(MeshGeometry3D mesh, Vector3D normal, Point3D upperLeft, Point3D lowerLeft, Point3D lowerRight, Point3D upperRight)
        {
            int offset = mesh.Positions.Count;

            mesh.Positions.Add(upperLeft);
            mesh.Positions.Add(lowerLeft);
            mesh.Positions.Add(lowerRight);
            mesh.Positions.Add(upperRight);

            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);

            mesh.TextureCoordinates.Add(new Point(0, 0));
            mesh.TextureCoordinates.Add(new Point(0, 1));
            mesh.TextureCoordinates.Add(new Point(1, 1));
            mesh.TextureCoordinates.Add(new Point(1, 0));

            mesh.TriangleIndices.Add(offset + 0);
            mesh.TriangleIndices.Add(offset + 1);
            mesh.TriangleIndices.Add(offset + 2);
            mesh.TriangleIndices.Add(offset + 0);
            mesh.TriangleIndices.Add(offset + 2);
            mesh.TriangleIndices.Add(offset + 3);

            return mesh;
        }
开发者ID:wjzhangb,项目名称:Fantasy.Repositories,代码行数:28,代码来源:Plane.cs

示例2: Calculate

        /// <summary>
        /// Calculates the texture for the specified model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        public override void Calculate(TerrainModel model, MeshGeometry3D mesh)
        {
            var normals = MeshGeometryHelper.CalculateNormals(mesh);
            var texcoords = new PointCollection();
            var up = new Vector3D(0, 0, 1);
            for (int i = 0; i < normals.Count; i++)
            {
                double slope = Math.Acos(Vector3D.DotProduct(normals[i], up)) * 180 / Math.PI;
                double u = slope / 40;
                if (u > 1)
                {
                    u = 1;
                }

                if (u < 0)
                {
                    u = 0;
                }

                texcoords.Add(new Point(u, u));
            }

            this.TextureCoordinates = texcoords;
            this.Material = MaterialHelper.CreateMaterial(this.Brush);
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:34,代码来源:SlopeTexture.cs

示例3: Plant

 public Plant()
 {
     var x = new Vector3D(1, 0, 0);
     var r1 = new RotateTransform3D(new AxisAngleRotation3D(x, 80));
     var r2 = new RotateTransform3D(new AxisAngleRotation3D(x, -70));
     var r3 = new RotateTransform3D(new AxisAngleRotation3D(x, -10));
     var t1 = new TranslateTransform3D(0, 0, 0.5);
     var t2 = new TranslateTransform3D(0, 0, 0.7);
     var t3 = new TranslateTransform3D(0, 0, 1.0);
     var s1 = new ScaleTransform3D(0.5, 0.5, 0.5);
     var s2 = new ScaleTransform3D(0.3, 0.3, 0.3);
     var s3 = new ScaleTransform3D(0.8, 0.8, 0.8);
     var m1 = new Transform3DGroup();
     m1.Children.Add(r1);
     m1.Children.Add(s1);
     m1.Children.Add(t1);
     var m2 = new Transform3DGroup();
     m2.Children.Add(r2);
     m2.Children.Add(s2);
     m2.Children.Add(t2);
     var m3 = new Transform3DGroup();
     m3.Children.Add(r3);
     m3.Children.Add(s3);
     m3.Children.Add(t3);
     T1 = m1;
     T2 = m2;
     T3 = m3;
 }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:28,代码来源:Plant.cs

示例4: end_effector

        //trajectory() in MATLAB; calculation position of end effector and ideal orientation of the needle
        public dof4 end_effector(Vector3D forearm_orientation, double delta_theta)
        {
            needle_holder_twist = needle_holder_twist  + t_incr;
            update_needle_holder_position();
            dof4 needle_holder;
            needle_holder.pos = needle_holder_position;
            needle_holder.twist = needle_holder_twist;

            print_vector(needle_holder_position);
            print_double(needle_holder_twist);
            /*
            set_circle_center(); // calculating center of needle
            // calculating position
            DOF.pos = new Vector3D(xc + r * Math.Sin(t), yc + r * Math.Cos(t), zc);

            // calculation orientation
            Vector3D centric1 = new Vector3D(r * Math.Sin(t), r * Math.Cos(t), 0);
            Vector3D centric2 = new Vector3D(r * Math.Sin(t + t_incr), r * Math.Cos(t + t_incr), 0);
            Vector3D normal = new Vector3D();
            //Vector3D ideal_needle_orientation = new Vector3D();
            normal = Vector3D.CrossProduct(centric1, centric2); // normal of circle plane
            ideal_needle_orientation = Vector3D.CrossProduct(centric1, normal); // which is the tangent of the path
            Vector3D optimal_needle_orientation = new Vector3D();
            optimal_needle_orientation = minimizer(forearm_orientation);
            DOF.ori = optimal_needle_orientation;
            */
            return needle_holder;
        }
开发者ID:surgical-robots,项目名称:robot-control-app,代码行数:29,代码来源:trajectory_version2.cs

示例5: EulerAngleToMatrix

		public static Matrix3D EulerAngleToMatrix(Vector3D pEulersAngles)
		{
			NewtonMatrix aNewtonMatrix = new NewtonMatrix(Matrix3D.Identity);
			Newton.NewtonSetEulerAngle(new NewtonVector3(pEulersAngles).NWVector3,
				aNewtonMatrix.NWMatrix);
			return aNewtonMatrix.ToDirectX();
		}
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:7,代码来源:CTransformUtility.cs

示例6: WWLineSegment

 public WWLineSegment(Point3D startPos, Vector3D dirNormalized, double length, double intensity)
 {
     StartPos = startPos;
     Direction = dirNormalized;
     Length = length;
     Intensity = intensity;
 }
开发者ID:kekyo,项目名称:PlayPcmWin,代码行数:7,代码来源:WWLineSegment.cs

示例7: angle

        public static double angle(Atom a, Atom b)
        {
            Vector3D va = new Vector3D(a.getX(), a.getY(), a.getZ());
                Vector3D vb = new Vector3D(b.getX(), b.getY(), b.getZ());

                return Vector3D.AngleBetween(va, vb);
        }
开发者ID:srujanjha,项目名称:PDBGraph,代码行数:7,代码来源:Calc.cs

示例8: NormalAt

 public Vector3D NormalAt(Vector3D intersectionPoint)
 {
     //Assert actually an intersection?
     var surfaceNormal = intersectionPoint - CenterPoint;
     surfaceNormal.Normalize();
     return surfaceNormal;
 }
开发者ID:csMACnz,项目名称:Monocle,代码行数:7,代码来源:Sphere.cs

示例9: Test

        public double? Test(Vector3D renderPoint, Vector3D direction)
        {
            var lineToCircle = renderPoint - CenterPoint;
            var B = 2 * Vector3D.DotProduct(direction, lineToCircle);
            var C = lineToCircle.LengthSquared - Math.Pow(Radius, 2);

            var determinate = Math.Pow(B, 2) - 4 * C;
            if (determinate >= 0)
            {
                var diff = Math.Sqrt(determinate);
                var tintersect1 = (-B - diff) / 2;
                var tintersect2 = (-B + diff) / 2;

                if (tintersect1 > tintersect2)
                {
                    var temp = tintersect2;
                    tintersect2 = tintersect1;
                    tintersect1 = temp;
                }
                if (tintersect1 < 0)
                {
                    tintersect1 = tintersect2;
                }
                if (tintersect1 >= 0)
                {
                    return tintersect1;
                }
            }
            return null;
        }
开发者ID:csMACnz,项目名称:Monocle,代码行数:30,代码来源:Sphere.cs

示例10: ModelRayIntersection

        public static bool ModelRayIntersection(WW3DModel model, Point3D rayOrig, Vector3D rayDir, out Point3D hitPos, out Vector3D hitSurfaceNormal, out double rayLength)
        {
            rayLength = double.MaxValue;
            hitPos = new Point3D();
            hitSurfaceNormal = new Vector3D();

            var points = model.TriangleList();
            var indices = model.IndexList();

            for (int i = 0; i < indices.Length/3; ++i) {
                Point3D pos;
                Vector3D surfaceNormal;
                double distance;
                if (!TriangleRayIntersect(points[indices[i * 3 + 0]], points[indices[i * 3 + 1]], points[indices[i * 3 + 2]], rayOrig, rayDir, out pos, out surfaceNormal, out distance)) {
                    continue;
                }
                if (distance < rayLength) {
                    hitPos = pos;
                    hitSurfaceNormal = surfaceNormal;
                    rayLength = distance;
                }
            }

            return rayLength != double.MaxValue;
        }
开发者ID:klangobjekte,项目名称:bitspersampleconv2,代码行数:25,代码来源:WWIntersection.cs

示例11: TriangleRayIntersect

        public static bool TriangleRayIntersect(Point3D p0, Point3D p1, Point3D p2, Point3D rayOrig, Vector3D rayDir, out Point3D hitPos, out Vector3D surfaceNormal, out double distance)
        {
            var edge01 = p1 - p0;
            var edge02 = p2 - p0;

            surfaceNormal = Vector3D.CrossProduct(edge01, edge02);
            surfaceNormal.Normalize();
            hitPos = new Point3D();
            distance = double.MaxValue;

            var p = Vector3D.CrossProduct(rayDir, edge02);
            var det = Vector3D.DotProduct(edge01, p);
            if (det < float.Epsilon) {
                // レイとトライアングルが平行 or backface
                return false;
            }

            var tvec = rayOrig - p0;
            var u = Vector3D.DotProduct(tvec,p);
            if (u < 0 || det < u) {
                return false;
            }

            var qvec = Vector3D.CrossProduct(tvec, edge01);
            var v = Vector3D.DotProduct(rayDir, qvec);
            if (v < 0 || det < u+v) {
                return false;
            }

            distance = Vector3D.DotProduct(edge02, qvec) / det;
            hitPos = rayOrig + distance * rayDir;
            return true;
        }
开发者ID:klangobjekte,项目名称:bitspersampleconv2,代码行数:33,代码来源:WWIntersection.cs

示例12: Ver

        public double Ver(DrawingContext dc, Target TargetA, Target TargetB, bool show)
        {
            //3D
            Vector3D vectorA = new Vector3D(TargetA.point3D().X - TargetB.point3D().X, TargetA.point3D().Y - TargetB.point3D().Y, 0);// TargetA.point3D().Z - TargetB.point3D().Z);
            Vector3D vectorB = new Vector3D(0, 1, 0);

            //2D
            //Vector3D vectorA = new Vector3D(TargetA.point2D().X - TargetB.point2D().X, TargetA.point2D().Y - TargetB.point2D().Y, 0);
            //Vector3D vectorB = new Vector3D(0, TargetA.point2D().Y - TargetB.point2D().Y, 0);

            double theta = Math.Abs(Vector3D.AngleBetween(vectorA, vectorB));
            if (TargetA.point3D().X < TargetB.point3D().X) theta = -theta;

            if (show)       //show angle text
            {
                dc.DrawText(new FormattedText(theta.ToString("f0"),
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Verdana"),
                25, brushLemonChiffon),
                new Point(TargetB.point2D().X - 35, TargetB.point2D().Y - 35));

                dc.DrawLine(PenLemonChiffon, TargetA.point2D(), TargetB.point2D());    //show angle line 
                //dc.DrawLine(PenLemonChiffon, new Point(TargetB.point2D().X, TargetA.point2D().Y), new Point(TargetB.point2D().X, TargetB.point2D().Y));  //show Vertical line
            }
            return theta;
        }
开发者ID:TrashTonyLin,项目名称:KinectCalAngle,代码行数:27,代码来源:AngleCalculator.cs

示例13: Hor

        public double Hor(DrawingContext dc, Target TargetA, Target TargetB ,bool show)
        {          
            //3D
            Vector3D vectorA = new Vector3D(TargetA.point3D().X - TargetB.point3D().X, TargetA.point3D().Y - TargetB.point3D().Y, TargetA.point3D().Z - TargetB.point3D().Z);
            Vector3D vectorB = new Vector3D(0, 1, 0);
            
            //2D
            //Vector3D vectorA = new Vector3D(TargetA.point2D().X - TargetB.point2D().X, TargetA.point2D().Y - TargetB.point2D().Y, 0);
            //Vector3D vectorB = new Vector3D(1, 0, 0);

            double theta = Math.Abs(Vector3D.AngleBetween(vectorA, vectorB));
            theta = 90 - theta;
            //if (TargetA.point3D().Y < TargetB.point3D().Y) theta = -theta;

            if (show)       //show angle text
            {
                dc.DrawText(new FormattedText(theta.ToString("f0"),
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Verdana"),
                25, brushDeepSkyBlue),
                new Point(TargetB.point2D().X - 35, TargetB.point2D().Y - 35));

                dc.DrawLine(PenDeepSkyBlue, TargetA.point2D(), TargetB.point2D());    //show angle line 
                dc.DrawLine(PenDeepSkyBlue, new Point(TargetA.point2D().X, TargetB.point2D().Y), TargetB.point2D());
            }
            return theta;
        }
开发者ID:TrashTonyLin,项目名称:KinectCalAngle,代码行数:28,代码来源:AngleCalculator.cs

示例14: CreateCap

        /// <summary>
        /// Helper method creates a triangle fan to close the ends of the cylinder.
        /// </summary>
        void CreateCap(int tessellation, float height, float radius, Vector3D normal)
        {
            // Create cap indices.
            for (int i = 0; i < tessellation - 2; i++)
            {
                if (normal.Y > 0)
                {
                    AddIndex(CurrentVertex);
                    AddIndex(CurrentVertex + (i + 1) % tessellation);
                    AddIndex(CurrentVertex + (i + 2) % tessellation);
                }
                else
                {
                    AddIndex(CurrentVertex);
                    AddIndex(CurrentVertex + (i + 2) % tessellation);
                    AddIndex(CurrentVertex + (i + 1) % tessellation);
                }
            }

            // Create cap vertices.
            for (int i = 0; i < tessellation; i++)
            {
                Vector3D vertex = GetCircleVector(i, tessellation) * radius +
                                   normal * height;
                Point3D vertexPoint = new Point3D(vertex.X, vertex.Y, vertex.Z);
                AddVertex(vertexPoint, normal);
            }
        }
开发者ID:OurDemoGroup,项目名称:Samples,代码行数:31,代码来源:CylinderPrimitive.cs

示例15: WWFirCoefficient

 public WWFirCoefficient(double delaySecond, Vector3D soundDir, double gain, bool isDirect)
 {
     DelaySecond = delaySecond;
     SoundDirection = soundDir;
     Gain = gain;
     IsDirect = isDirect;
 }
开发者ID:klangobjekte,项目名称:bitspersampleconv2,代码行数:7,代码来源:WWFirCoefficient.cs


注:本文中的System.Windows.Media.Media3D.Vector3D类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。