• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Vector2F类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ImageBillboard

 /// <summary>
 /// Initializes a new instance of the <see cref="ImageBillboard"/> class.
 /// </summary>
 /// <param name="texture">The texture.</param>
 public ImageBillboard(PackedTexture texture)
 {
     Texture = texture;
       Size = new Vector2F(1, 1);
       _alphaTest = 0;
       _blendMode = 1;
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:11,代码来源:ImageBillboard.cs


示例2: OnArrange

        /// <inheritdoc/>
        protected override void OnArrange(Vector2F position, Vector2F size)
        {
            // Get extreme positions of arrange area.
            float left = position.X;
            float top = position.Y;
            float right = left + size.X;
            float bottom = top + size.Y;

            if (Orientation == DigitalRune.Game.UI.Orientation.Horizontal)
            {
                // ----- Horizontal:
                // Each child gets its desired width or the rest of the available space.
                foreach (var child in VisualChildren)
                {
                    float availableSize = Math.Max(0.0f, right - left);
                    float sizeX = Math.Min(availableSize, child.DesiredWidth);
                    float sizeY = size.Y;
                    child.Arrange(new Vector2F(left, top), new Vector2F(sizeX, sizeY));
                    left += sizeX + 10;
                }
            }
            else
            {
                // ----- Vertical
                // Each child gets its desired height or the rest of the available space.
                foreach (var child in VisualChildren)
                {
                    float sizeX = size.X;
                    float availableSize = Math.Max(0.0f, bottom - top);
                    float sizeY = Math.Min(availableSize, child.DesiredHeight);
                    child.Arrange(new Vector2F(left, top), new Vector2F(sizeX, sizeY));
                    top += sizeY + 10;
                }
            }
        }
开发者ID:FirestarJes,项目名称:MasterOfOrion,代码行数:36,代码来源:SpacedStackPanel.cs


示例3: Intersects

        /// <summary>
        ///   Checks whether the specified line segment intersects the passed one.
        /// </summary>
        /// <remarks>
        ///   See http://www.wyrmtale.com/blog/2013/115/2d-line-intersection-in-c for details.
        /// </remarks>
        /// <param name="first">Line segment to check.</param>
        /// <param name="second">Line segment to check.</param>
        /// <param name="intersectionPoint">Intersection point, if found.</param>
        /// <returns>
        ///   <c>true</c>, if both line segments intersect each other, and <c>false</c> otherwise.
        /// </returns>
        public static bool Intersects(this LineSegment2F first, LineSegment2F second, out Vector2F intersectionPoint)
        {
            // Get A,B,C of first line - points ps1 to pe1.
            var a1 = first.Q.Y - first.P.Y;
            var b1 = first.P.X - first.Q.X;
            var c1 = a1 * first.P.X + b1 * first.P.Y;

            // Get A,B,C of second line - points ps2 to pe2.
            var a2 = second.Q.Y - second.P.Y;
            var b2 = second.P.X - second.Q.X;
            var c2 = a2 * second.P.X + b2 * second.P.Y;

            // Get delta and check if the lines are parallel.
            var delta = a1 * b2 - a2 * b1;

            if (Math.Abs(delta) < float.Epsilon)
            {
                intersectionPoint = Vector2F.Zero;
                return false;
            }

            // Return intersection point.
            intersectionPoint = new Vector2F((b2 * c1 - b1 * c2) / delta, (a1 * c2 - a2 * c1) / delta);
            return first.Contains(intersectionPoint) && second.Contains(intersectionPoint);
        }
开发者ID:npruehs,项目名称:game-math,代码行数:37,代码来源:LineIntersection.cs


示例4: Addition

 public void Addition()
 {
     Vector2F a = new Vector2F(1.0f, 2.0f);
       Vector2F b = new Vector2F(2.0f, 3.0f);
       Vector2F c = Vector2F.Add(a, b);
       Assert.AreEqual(new Vector2F(3.0f, 5.0f), c);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:Vector2FTest.cs


示例5: AdditionOperator

 public void AdditionOperator()
 {
     Vector2F a = new Vector2F(1.0f, 2.0f);
       Vector2F b = new Vector2F(2.0f, 3.0f);
       Vector2F c = a + b;
       Assert.AreEqual(new Vector2F(3.0f, 5.0f), c);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:Vector2FTest.cs


示例6: OrientedBox

 /// <summary>
 /// Initializes a new instance of the <see cref="OrientedBox"/> class using given center point, axes and extents.
 /// </summary>
 /// <param name="center">The center of the box.</param>
 /// <param name="axis1">The first axis.</param>
 /// <param name="axis2">The second axis.</param>
 /// <param name="extent1">The extent on the first axis.</param>
 /// <param name="extent2">The extent on the second axis.</param>
 public OrientedBox(Vector2F center, Vector2F axis1, Vector2F axis2, float extent1, float extent2)
 {
     _center = center;
     _axis1 = axis1;
     _axis2 = axis2;
     _extent1 = extent1;
     _extent2 = extent2;
 }
开发者ID:GameProduction,项目名称:ScharfschiessenGame,代码行数:16,代码来源:OrientedBox.cs


示例7: TestPolygonContainsPoint

        public void TestPolygonContainsPoint()
        {
            // ARRANGE.
            var point = new Vector2F(3, 3);

            // ASSERT.
            Assert.IsTrue(this.polygon.Contains(point));
        }
开发者ID:npruehs,项目名称:game-math,代码行数:8,代码来源:PolygonTests.cs


示例8: TestRectangleFCenter

        public void TestRectangleFCenter()
        {
            // ARRANGE.
            var rectangle = new RectangleF(new Vector2F(2, 3), new Vector2F(6, 8));
            var center = new Vector2F(5, 7);

            // ASSERT.
            Assert.AreEqual(center, rectangle.Center);
        }
开发者ID:npruehs,项目名称:game-math,代码行数:9,代码来源:RectangleTests.cs


示例9: Planet

        public Planet(IServiceProvider services, SystemMapPlanetViewModel viewModel)
        {
            ViewModel = viewModel;
            Scale = ViewModel.Scale;

            ImageControl = new Image();

            _content = (ContentController)services.GetService(typeof(ContentController));
            ImageControl.Texture = _content.GetContent<Texture2D>(@"SystemMap\Planet1");
            Content = ImageControl;
            RenderScale = new Vector2F(Scale);
        }
开发者ID:FirestarJes,项目名称:MasterOfOrion,代码行数:12,代码来源:Planet.cs


示例10: Normalize

        public void Normalize()
        {
            Vector2F v, n1, n2;
            float magnitude;

            v = new Vector2F(3.0f, 4.0f);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0f, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0f, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0f, magnitude, 1e-14);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:12,代码来源:Vector2FTests.cs


示例11: Absolute

        public void Absolute()
        {
            Vector2F v = new Vector2F(-1, -2);
              v.Absolute();

              Assert.AreEqual(1, v.X);
              Assert.AreEqual(2, v.Y);

              v = new Vector2F(1, 2);
              v.Absolute();
              Assert.AreEqual(1, v.X);
              Assert.AreEqual(2, v.Y);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:13,代码来源:Vector2FTest.cs


示例12: AbsoluteStatic

        public void AbsoluteStatic()
        {
            Vector2F v = new Vector2F(-1, -2);
              Vector2F absoluteV = Vector2F.Absolute(v);

              Assert.AreEqual(1, absoluteV.X);
              Assert.AreEqual(2, absoluteV.Y);

              v = new Vector2F(1, 2);
              absoluteV = Vector2F.Absolute(v);
              Assert.AreEqual(1, absoluteV.X);
              Assert.AreEqual(2, absoluteV.Y);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:13,代码来源:Vector2FTest.cs


示例13: Update

        private void Update(Context context)
        {
            if (_positionDirty)
            {
                DisposeVertexArray();
                CreateVertexArray(context);

                Vector2F[] positions = new Vector2F[] { _position.ToVector2F() };
                _positionBuffer.CopyFromSystemMemory(positions);

                _positionDirty = false;
            }
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:13,代码来源:HeadsUpDisplay.cs


示例14: Subtract

        public void Subtract()
        {
            Vector2F v1 = new Vector2F(1.0f, 2.0f);
            Vector2F v2 = new Vector2F(4.0f, 5.0f);

            Vector2F v3 = v1 - v2;
            Assert.AreEqual(-3.0f, v3.X, 1e-14);
            Assert.AreEqual(-3.0f, v3.Y, 1e-14);

            Vector2F v4 = v1.Subtract(v2);
            Assert.AreEqual(-3.0f, v4.X, 1e-14);
            Assert.AreEqual(-3.0f, v4.Y, 1e-14);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:13,代码来源:Vector2FTests.cs


示例15: Add

        public void Add()
        {
            Vector2F v1 = new Vector2F(1.0f, 2.0f);
            Vector2F v2 = new Vector2F(4.0f, 5.0f);

            Vector2F v3 = v1 + v2;
            Assert.AreEqual(5.0f, v3.X, 1e-14);
            Assert.AreEqual(7.0f, v3.Y, 1e-14);

            Vector2F v4 = v1.Add(v2);
            Assert.AreEqual(5.0f, v4.X, 1e-14);
            Assert.AreEqual(7.0f, v4.Y, 1e-14);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:13,代码来源:Vector2FTests.cs


示例16: AreEqual

        public void AreEqual()
        {
            float originalEpsilon = Numeric.EpsilonF;
              Numeric.EpsilonF = 1e-8f;

              Vector2F u = new Vector2F(1.0f, 2.0f);
              Vector2F v = new Vector2F(1.000001f, 2.000001f);
              Vector2F w = new Vector2F(1.00000001f, 2.00000001f);

              Assert.IsTrue(Vector2F.AreNumericallyEqual(u, u));
              Assert.IsFalse(Vector2F.AreNumericallyEqual(u, v));
              Assert.IsTrue(Vector2F.AreNumericallyEqual(u, w));

              Numeric.EpsilonF = originalEpsilon;
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:15,代码来源:Vector2FTest.cs


示例17: NormalMapDistortionFilter

        private int _blurLevel; // TODO: We could add more levels with Poisson blur, etc.

        #endregion Fields

        #region Constructors

        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="NormalMapDistortionFilter"/> class.
        /// </summary>
        /// <param name="graphicsService">The graphics service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicsService"/> is <see langword="null"/>.
        /// </exception>
        public NormalMapDistortionFilter(IGraphicsService graphicsService)
            : base(graphicsService)
        {
            _effect = GraphicsService.Content.Load<Effect>("DigitalRune/PostProcessing/NormalMapDistortionFilter");
              _viewportSizeParameter = _effect.Parameters["ViewportSize"];
              _scaleParameter = _effect.Parameters["Scale"];
              _offsetParameter = _effect.Parameters["Offset"];
              _strengthParameter = _effect.Parameters["Strength"];
              _sourceTextureParameter = _effect.Parameters["SourceTexture"];
              _normalMapParameter = _effect.Parameters["NormalMap"];
              _basicPass = _effect.CurrentTechnique.Passes["Basic"];
              _blur4Pass = _effect.CurrentTechnique.Passes["Blur4"];

              Scale = new Vector2F(1);
              Strength = 10;
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:30,代码来源:NormalMapDistortionFilter.cs


示例18: SkyObjectNode

        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="SkyObjectNode" /> class.
        /// </summary>
        public SkyObjectNode()
        {
            AngularDiameter = new Vector2F(MathHelper.ToRadians(5));
              Alpha = 1;
              SunDirection = new Vector3F(1, 1, 1);
              SunLight = new Vector3F(1, 1, 1);
              AmbientLight = new Vector3F(0, 0, 0);
              LightWrap = 0.1f;
              LightSmoothness = 1;

              GlowColor0 = new Vector3F(0.1f);
              GlowExponent0 = 200;
              GlowColor1 = new Vector3F(0, 0, 0);
              GlowExponent0 = 4000;
              GlowCutoffThreshold = 0.001f;
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:20,代码来源:SkyObjectNode.cs


示例19: NormalizeZeroVector

        public void NormalizeZeroVector()
        {
            Vector2F v = new Vector2F(0.0f, 0.0f);

            Vector2F n1 = v.Normalize();
            Assert.IsNaN(n1.X);
            Assert.IsNaN(n1.Y);
            Assert.IsTrue(n1.IsUndefined);

            float magnitude;
            Vector2F n2 = v.Normalize(out magnitude);
            Assert.IsNaN(n2.X);
            Assert.IsNaN(n2.Y);
            Assert.IsTrue(n2.IsUndefined);
            Assert.AreEqual(0.0f, magnitude);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:16,代码来源:Vector2FTests.cs


示例20: Update

        internal void Update(Context context, ShaderProgram sp)
        {
            if (_va == null)
            {
                VertexBufferAttribute positionAttribute = new VertexBufferAttribute(
                    _positionBuffer, ComponentDatatype.Float, 2);
                VertexBufferAttribute textureCoordinatesAttribute = new VertexBufferAttribute(
                    _textureCoordinatesBuffer, ComponentDatatype.HalfFloat, 2);

                _va = context.CreateVertexArray();
                _va.Attributes[sp.VertexAttributes["position"].Location] = positionAttribute;
                _va.Attributes[sp.VertexAttributes["textureCoordinates"].Location] = textureCoordinatesAttribute;
            }

            if (_viewport != context.Viewport)
            {
                //
                // Bottom and top swapped:  MS -> OpenGL
                //
                float left = context.Viewport.Left;
                float bottom = context.Viewport.Top;
                float right = context.Viewport.Right;
                float top = context.Viewport.Bottom;

                Vector2F[] positions = new Vector2F[] 
                { 
                    new Vector2F(left, bottom), 
                    new Vector2F(right, bottom), 
                    new Vector2F(left, top), 
                    new Vector2F(right, top)
                };
                _positionBuffer.CopyFromSystemMemory(positions);

                Vector2H[] textureCoordinates = new Vector2H[] 
                { 
                    new Vector2H(0, 0), 
                    new Vector2H(1, 0), 
                    new Vector2H(0, 1), 
                    new Vector2H(1, 1)
                };
                _textureCoordinatesBuffer.CopyFromSystemMemory(textureCoordinates);

                _viewport = context.Viewport;
            }
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:45,代码来源:ViewportQuadGeometry.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Vector2I类代码示例发布时间:2022-05-24
下一篇:
C# Vector2D类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap