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


C# Plane.ToString方法代码示例

本文整理汇总了C#中Plane.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.ToString方法的具体用法?C# Plane.ToString怎么用?C# Plane.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plane的用法示例。


在下文中一共展示了Plane.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToStringTest

        public void ToStringTest()
        {
            Plane target = new Plane(-12, 3, -18, 1);

            {
                string expected = "-12x +3y -18z +1 = 0";
                string actual = target.ToString();
                Assert.AreEqual(expected, actual);
            }

            {
                string expected = "x = +0.25y -1.5z +0.08333334";
                string actual = target.ToString('x', CultureInfo.InvariantCulture);
                Assert.AreEqual(expected, actual);
            }
        }
开发者ID:CanerPatir,项目名称:framework,代码行数:16,代码来源:PlaneTest.cs

示例2: PlaneToStringTest

        public void PlaneToStringTest()
        {
            Plane target = new Plane(1, 2, 3, 4);
            string expected = string.Format(
                CultureInfo.CurrentCulture,
                "{{Normal:{0:G} D:{1}}}",
                target.Normal,
                target.D);

            Assert.Equal(expected, target.ToString());
        }
开发者ID:jsalvadorp,项目名称:corefx,代码行数:11,代码来源:PlaneTests.cs

示例3: PlaneToStringTest

 public void PlaneToStringTest()
 {
     Plane target = new Plane(1.0f, 2.0f, 3.0f, 4.1f);
     string expected = "{Normal:{X:1 Y:2 Z:3} D:4.1}";
     string actual = target.ToString();
     Assert.AreEqual(expected, actual, "Plane.ToString did not return the expected value.");
 }
开发者ID:fengweijp,项目名称:Win2D,代码行数:7,代码来源:PlaneTest.cs

示例4: ConvertQuakeEdTo220

        static List<string> ConvertQuakeEdTo220(List<string> lines_in)
        {
            List<string> lines_out = new List<string>();

            // The order of planes here is specifically designed to match up
            // with the texture orientation results provided by editors and
            // compilers. First -Z and its normal-flipped counterpart, then -X
            // and its alternative, and finally -Y.
            List<Plane> cardinals = new List<Plane>() {
                new Plane("(0 0 0) (1 0 0) (0 -1 0)"), // XY, normal points toward -Z
                new Plane("(0 0 0) (1 0 0) (0 -1 0)", true),
                new Plane("(0 0 0) (0 1 0) (0 0 -1)"), // YZ, normal points toward -X
                new Plane("(0 0 0) (0 1 0) (0 0 -1)", true),
                new Plane("(0 0 0) (1 0 0) (0 0 -1)"), // ZX, normal points toward -Y
                new Plane("(0 0 0) (1 0 0) (0 0 -1)", true)};

            for (int i = 0; i < lines_in.Count; ++i) {
                string line_in = Quinstance.Util.StripComment(lines_in[i]);
                string trimmed = line_in.Trim();
                if (!trimmed.StartsWith("(")) {
                    if (i > 0 && lines_in[i - 1].Trim().EndsWith("\"worldspawn\""))
                        lines_out.Add("\"mapversion\" \"220\"");
                    lines_out.Add(line_in);
                    continue;
                }

                string indent = line_in.Substring(0, line_in.IndexOf('('));
                Plane p = new Plane(line_in.Substring(line_in.IndexOf('('), line_in.LastIndexOf(')') + 1));
                char[] texinfo_delims = { ' ' };
                string[] texinfo = line_in.Substring(line_in.LastIndexOf(')') + 1).Split(texinfo_delims, StringSplitOptions.RemoveEmptyEntries);

                double smallest_angle = 180.0;
                Plane closest_plane = cardinals[0];
                foreach (Plane q in cardinals) {
                    double current_angle = Quin3d.Util.UnsignedAngleBetweenVectors(p.normal, q.normal);
                    if (current_angle < smallest_angle) {
                        closest_plane = q;
                        smallest_angle = current_angle;
                    }
                }

                double angle;
                Double.TryParse(texinfo[3], out angle);

                // TODO: Add something for angle == 0.0!

                double cos = Math.Cos(angle * (System.Math.PI / 180.0)),
                       sin = Math.Sin(angle * (System.Math.PI / 180.0));

                Matrix3x3 matrix_x = new Matrix3x3(new double[] { 1.0,  0.0,  0.0,
                                                                  0.0,  cos, -sin,
                                                                  0.0,  sin,  cos }),

                          matrix_y = new Matrix3x3(new double[] { cos,  0.0,  sin,
                                                                  0.0,  1.0,  0.0,
                                                                 -sin,  0.0,  cos }),

                          matrix_z = new Matrix3x3(new double[] { cos, -sin,  0.0,
                                                                  sin,  cos,  0.0,
                                                                  0.0,  0.0,  1.0 });

                Matrix3x3 matrix = new Matrix3x3();

                // Equality checks for doubles, I know, but in this case the
                // only possible values of 'closest_plane' will have normals
                // with exact coordinates. I hope.
                if (closest_plane.normal.x == 1.0 || closest_plane.normal.x == -1.0)
                    matrix = matrix_x;
                else if (closest_plane.normal.y == 1.0 || closest_plane.normal.y == -1.0)
                    matrix = matrix_y;
                else
                    matrix = matrix_z;
                Point3d rot_b = Quin3d.Util.MulMatrix3x3ByPoint3d(matrix, closest_plane.b);
                Point3d rot_c = Quin3d.Util.MulMatrix3x3ByPoint3d(matrix, closest_plane.c);

                // Each cardinal plane's vectors are assumed to start at 0 0 0,
                // which means no need to subtract anything to get the actual
                // vectors to use here, just throw in the values.
                lines_out.Add(indent + p.ToString() + ' ' + texinfo[0] + ' ' +
                              rot_b.ToString().Replace('(', '[').Replace(")", "") + texinfo[1] + " ] " +
                              rot_c.ToString().Replace('(', '[').Replace(")", "") + texinfo[2] + " ] " +
                              texinfo[3] + ' ' + texinfo[4] + ' ' + texinfo[5]);
            }
            return lines_out;
        }
开发者ID:ItEndsWithTens,项目名称:Quinstance,代码行数:85,代码来源:Program.cs


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