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

C# Windows.Vector类代码示例

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

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



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

示例1: TestingCompoundVertexInfo

 public TestingCompoundVertexInfo(Vector springForce, Vector repulsionForce, Vector gravityForce, Vector applicationForce)
 {
     SpringForce = springForce;
     RepulsionForce = repulsionForce;
     GravityForce = gravityForce;
     ApplicationForce = applicationForce;
 }
开发者ID:KevinCathcart,项目名称:GraphX,代码行数:7,代码来源:TestingCompoundVertexInfo.cs


示例2: NodeViewModel

        public NodeViewModel(Node node, Vector location, IControlTypesResolver controlTypesResolver)
        {
            Node = node;
            Title = node.Title;
            Location = new CanvasPoint(location);
            ControlTypesResolver = controlTypesResolver;

            foreach (var pin in node.InputPins)
            {
                AddInputPin(pin);
            }

            foreach (var pin in node.OutputPins)
            {
                AddOutputPin(pin);
            }

            node.Processed += OnNodeProcessed;
            node.PinsChanged += OnNodePinsChanged;

            _disposable = Disposable.Create(() =>
            {
                node.PinsChanged -= OnNodePinsChanged;
                node.Processed -= OnNodeProcessed;
            });
        }
开发者ID:misupov,项目名称:Turbina,代码行数:26,代码来源:NodeViewModel.cs


示例3: TestBoundingCirclePushBackLeftTop

        public void TestBoundingCirclePushBackLeftTop()
        {
            //Preconfig
            int radius = 20;
            Vector position = new Vector(100f, 100f);
            Vector ballPos = new Vector(100, 100);
            Vector hitPoint = new Vector(120 - 14.1421f, 120 - 14.1421f);

            Vector ballSpeed = hitPoint - ballPos;

            Vector expectedPushBack = (radius * 2 / 1.9f) * ((hitPoint - (position + new Vector(radius, radius)))).AsNormalized();

            Vector pushBackVec;

            //Creation
            Bumper parent = new Bumper();
            BoundingCircle bC2 = new BoundingCircle(radius, position);
            BoundingContainer bCont = new BoundingContainer(parent);
            bCont.AddBoundingBox(bC2);

            //Operation
            parent.Location = (new Vector(0, 0));
            pushBackVec = bC2.GetOutOfAreaPush(radius * 2, hitPoint, ballSpeed, ballPos);

            //Assertion
            Assert.AreEqual(expectedPushBack, pushBackVec);
        }
开发者ID:EusthEnoptEron,项目名称:Sketchball,代码行数:27,代码来源:BoundingCircle_pushBack.cs


示例4: ApplyFilter

		public override void ApplyFilter(int[] pixels, int width, int height, Vector[,] field)
		{
			double maxLength = Double.NegativeInfinity;
			double minLength = Double.PositiveInfinity;

			for (int ix = 0; ix < width; ix++)
			{
				for (int iy = 0; iy < height; iy++)
				{
					var length = field[ix, iy].Length;
					if (length > maxLength) maxLength = length;
					if (length < minLength) minLength = length;
				}
			}

			for (int i = 0; i < width * height; i++)
			{
				HsbColor color = HsbColor.FromArgb(pixels[i]);

				int ix = i % width;
				int iy = i / width;
				var length = field[ix, iy].Length;

				var ratio = (length - minLength) / (maxLength - minLength);
				if (ratio.IsNaN())
					ratio = 0;

				var paletteColor = Palette.GetColor(ratio).ToHsbColor();

				color.Hue = paletteColor.Hue;
				color.Saturation = paletteColor.Saturation;

				pixels[i] = color.ToArgb();
			}
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:35,代码来源:MagnitudeFilter.cs


示例5: IrregularCell

		public IrregularCell(Vector leftBottom, Vector rightBottom, Vector rightTop, Vector leftTop)
		{
			this.leftBottom = leftBottom;
			this.rightBottom = rightBottom;
			this.rightTop = rightTop;
			this.leftTop = leftTop;
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:7,代码来源:CellInfo.cs


示例6: Vertex

 // Constructor function
 public Vertex(int id, Vector position, HashSet<int> connections)
 {
     this.ID = id;
     this.PositionVector = position;
     this.connectedVertexIDs = connections;
     this.mass = 1;
 }
开发者ID:michielvh1995,项目名称:OMI,代码行数:8,代码来源:Vertex.cs


示例7: RandomBellArgs

        /// <summary>
        /// Play with the NonlinearRandom tester to come up with values
        /// </summary>
        public RandomBellArgs(double leftArmLength, double leftArmAngle, double rightArmLength, double rightArmAngle)
        {
            List<Point3D> controlPoints = new List<Point3D>();

            // Arm1
            if (!leftArmLength.IsNearZero())
            {
                Vector arm1 = new Vector(1, 1).ToUnit() * leftArmLength;

                controlPoints.Add(arm1.ToVector3D().GetRotatedVector(new Vector3D(0, 0, -1), leftArmAngle).ToPoint());
            }

            // Arm2
            if (!rightArmLength.IsNearZero())
            {
                Vector arm2 = new Vector(-1, -1).ToUnit() * rightArmLength;

                Vector3D arm2Rotated = arm2.
                    ToVector3D().
                    GetRotatedVector(new Vector3D(0, 0, -1), rightArmAngle);

                controlPoints.Add(new Point3D(1 + arm2Rotated.X, 1 + arm2Rotated.Y, 0));
            }

            // Bezier
            this.Bezier = new BezierSegment3D(0, 1, controlPoints.ToArray(), new[] { new Point3D(0, 0, 0), new Point3D(1, 1, 0) });
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:30,代码来源:StaticRandomWPF.cs


示例8: Character

 /// <summary>
 /// Initializes a new character instance.
 /// </summary>
 /// <param name="p0">Lower left character position.</param>
 /// <param name="size">Size of the character.</param>
 /// <param name="uiTaskSchedule">Scheduler associated with the UI thread.</param>
 public Character(Point p0, Vector size, TaskScheduler uiTaskSchedule)
     : base(uiTaskSchedule)
 {
     this.Position = new Quadrilateral(p0, size);
     this.Gravity = CharacterGravityState.Down;
     this.Animation = CharacterAnimationState.Down;
 }
开发者ID:ronforbes,项目名称:GravityGuy,代码行数:13,代码来源:Character.cs


示例9: GetWaypoint

        public override Point GetWaypoint()
        {
            // update collided point status
            _me.SetStatus(_mo.X, _mo.Y, MapElementStatus.Collided);

            Vector vector = new Vector(_mo.X - _posX, _mo.Y - _posY);
            
            // opposite direction
            vector.Negate();

            // normalize vector (length = 1)
            vector.Normalize();

            // calculate distances to every border
            double tLeft = (-_posX) / vector.X;
            double tRight = (800 - _posX) / vector.X;
            double tTop = (-_posY) / vector.Y;
            double tBottom = (600 - _posY) / vector.Y;

            vector *= 20;

            _point.X = (int)_posX + (int)vector.X;
            _point.Y = (int)_posY + (int)vector.Y;

            _point.Status = MapElementStatus.Waypoint;

            return _point;
        }
开发者ID:villj2,项目名称:ch.bfh.bti7301.searchrobot,代码行数:28,代码来源:WayDecisionCollision.cs


示例10: Equals

		public void Equals ()
		{
			Vector v = new Vector (4, 5);
			Assert.IsTrue (v.Equals (new Vector (4, 5)));
			Assert.IsFalse (v.Equals (new Vector (5, 4)));
			Assert.IsFalse (v.Equals (new object()));
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:VectorTest.cs


示例11: ByteTagDefinition

 /// <summary>
 /// Private constructor.
 /// </summary>
 /// <param name="physicalCenterOffsetFromTag"></param>
 /// <param name="orientationOffsetFromTag"></param>
 private ByteTagDefinition(
     Vector physicalCenterOffsetFromTag,
     double orientationOffsetFromTag)
 {
     this.physicalCenterOffsetFromTag = physicalCenterOffsetFromTag;
     this.orientationOffsetFromTag = orientationOffsetFromTag;
 }
开发者ID:AnthonyB28,项目名称:Marist_Map,代码行数:12,代码来源:ByteTagDefinition.cs


示例12: GetClosestComponent

        public Component GetClosestComponent(int x, int y, ComponentFilter cf)
        {
            Component result = null;
            int componentType = cf.Type;
            List<Component> components = m_vComponents[componentType];
            Vector v = new Vector(x,y);
            double maxLengthSquared = 0;

            if (components.Count > 0)
            {
                foreach(var c in components)
                {
                    if(cf.TestComponent(c))
                    {
                        GameObject go = c.GetParent();
                        double lengthSquared = (v - go.GetPosition()).LengthSquared; 
                        if(lengthSquared < maxLengthSquared || result == null)
                        {
                            maxLengthSquared = lengthSquared;
                            result = c;
                        }
                    }
                }
            }
            return result;
        }
开发者ID:0trebor0,项目名称:clash-of-warriors-server,代码行数:26,代码来源:ComponentManager.cs


示例13: TestBoundingLineReflect270Left

        public void TestBoundingLineReflect270Left()
        {
            //Preconfig
            Vector position1 = new Vector(0f, 50f);
            Vector target1 = new Vector(50f, 50f);

            Vector ballSpeed = new Vector(5, 0);
            Vector ballPos = new Vector(-20, 50);

            Vector hitPoint = new Vector(0, 50);
            Vector expectedReflection = -ballSpeed;
            expectedReflection.Normalize();
            Vector reflection;

            //Creation
            Line parent = new Line();
            BoundingContainer bCont = new BoundingContainer(parent);
            BoundingLine bL1 = new BoundingLine(position1, target1);
            bCont.AddBoundingBox(bL1);
            parent.Location = (new Vector(0, 0));

            //Operation
            reflection = bL1.Reflect(ballSpeed, hitPoint, ballPos);
            reflection.Normalize();

            //Assertion
            Assert.AreEqual(expectedReflection, reflection);
        }
开发者ID:EusthEnoptEron,项目名称:Sketchball,代码行数:28,代码来源:BoundingLine_reflect.cs


示例14: Physics

 public Physics(GameObject gameObject, double topSpeed, Vector velocity)
 {
     _lastUpdate = DateTime.Now.Ticks;
     GameObject = gameObject;
     _topSpeed = topSpeed;
     Velocity = velocity;
 }
开发者ID:ChrisDaBang,项目名称:BOD-Server,代码行数:7,代码来源:Physics.cs


示例15: Subdivide

        public static Tuple<Point[], Point[], Point[]> Subdivide(Point[] l1, Point[] l2)
        {
            var allPoints = l1.Concat(l2).ToArray();
            var pcaLine = PCALine.Compute(allPoints);

            var minPoint = allPoints.Minimizer(p => ProjectedLinePosition(p, pcaLine.Item1, pcaLine.Item2)).ProjectOnLine(pcaLine);
            var maxPoint = allPoints.Minimizer(p => -ProjectedLinePosition(p, pcaLine.Item1, pcaLine.Item2)).ProjectOnLine(pcaLine);

            var samples = SampleSegment(minPoint, maxPoint);

            var points1 = new List<Point>();
            var points2 = new List<Point>();
            var centers = new List<Point>();
            var perp = new Vector(-pcaLine.Item2.Y, pcaLine.Item2.X);
            for (int i = 0; i < samples.Length; ++i)
            {
                var p1 = DirectionalProject(samples[i], perp, l1);
                var p2 = DirectionalProject(samples[i], perp, l2);
                if (p1 != null && p2 != null)
                {
                    points1.Add(p1.Value);
                    points2.Add(p2.Value);
                    centers.Add(samples[i]);
                }
            }

            return Tuple.Create(points1.ToArray(), points2.ToArray(), centers.ToArray());
        }
开发者ID:alexshtf,项目名称:Various-utility-projects,代码行数:28,代码来源:SilhouettesSubdividor.cs


示例16: HitTestPolygonSegment

        /// <summary>
        /// Hit-tests a linear segment against a convex polygon. 
        /// </summary>
        /// <param name="vertices">Vertices of the polygon (in clockwise order)</param>
        /// <param name="hitBegin">an end point of the hitting segment</param>
        /// <param name="hitEnd">an end point of the hitting segment</param> 
        /// <returns>true if hit; false otherwise</returns>
        internal static bool HitTestPolygonSegment(Vector[] vertices, Vector hitBegin, Vector hitEnd) 
        { 
            System.Diagnostics.Debug.Assert((null != vertices) && (2 < vertices.Length));
 
            HitResult hitResult = HitResult.Right, firstResult = HitResult.Right, prevResult = HitResult.Right;
            int count = vertices.Length;
            Vector vertex = vertices[count - 1];
            for (int i = 0; i < count; i++) 
            {
                Vector nextVertex = vertices[i]; 
                hitResult = WhereIsSegmentAboutSegment(hitBegin, hitEnd, vertex, nextVertex); 
                if (HitResult.Hit == hitResult)
                { 
                    return true;
                }
                if (IsOutside(hitResult, prevResult))
                { 
                    return false;
                } 
                if (i == 0) 
                {
                    firstResult = hitResult; 
                }
                prevResult = hitResult;
                vertex = nextVertex;
            } 
            return (false == IsOutside(firstResult, hitResult));
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:35,代码来源:StrokeNodeOperations2.cs


示例17: LineIntersectSegment

        private static bool LineIntersectSegment(Point p, Vector v, Point segStart, Point segEnd, out Point result)
        {
            var a11 = v.X;
            var a12 = segStart.X - segEnd.X;
            var a21 = v.Y;
            var a22 = segStart.Y - segEnd.Y;
            var b1 = segStart.X - p.X;
            var b2 = segStart.Y - p.Y;

            var solution = LinearSolve(a11, a12, a21, a22, b1, b2);
            if (solution != null)
            {
                var beta = solution.Value.Y;
                result = segStart + beta * (segEnd - segStart);
                if (beta < 0 || beta > 1)
                    return false;
                else
                    return true;

            }
            else
            {
                result = default(Point);
                return false;
            }
        }
开发者ID:alexshtf,项目名称:Various-utility-projects,代码行数:26,代码来源:SilhouettesSubdividor.cs


示例18: AngleBetweenVectors

        // TODO: Change to less case-specific methods (e.g. have vectors in input)
        // Angle between two vectors: one from a MovingEntity (origin to planned position), one with a new point (origin to a detected point)
        public static double AngleBetweenVectors(MovingEntity entity, MovingEntity newEntity)
        {
            Vector originalVector = new Vector(entity.DeltaX, entity.DeltaY);
            Vector newVector = new Vector(newEntity.Position.X - entity.Position.X, newEntity.Position.Y - entity.Position.Y);

            return Vector.AngleBetween(originalVector, newVector);
        }
开发者ID:CRIAAC,项目名称:UltrasoundTracking,代码行数:9,代码来源:DataCompute.cs


示例19: h_changePosition

        private void h_changePosition()
        {
            Point playerPosition = Info.GetPlayerPosition();

            Vector distance = new Vector(playerPosition.X - Position.X, playerPosition.Y - Position.Y);
            double coef = distance.X / MaxSpeed;

            Vector movement = Vector.Divide(distance, coef);

            Size levelSize = Info.GetLevelSize();

            if(movement.X > levelSize.Width)
              movement = new Vector(levelSize.Width, movement.Y);

            if(movement.X < 0 || double.IsNaN(movement.X))
              movement = new Vector(0, movement.Y);

            if(movement.Y > levelSize.Height)
              movement = new Vector(movement.X, levelSize.Height);

            if(movement.Y < 0 ||  double.IsNaN(movement.Y))
              movement = new Vector(movement.X, 0);

            Position = new Point((int) (Position.X + movement.X), (int) (Position.Y + movement.Y));

            Position = new Point((int)(Position.X+ 1), (int)(Position.Y + 1));
        }
开发者ID:krivyshin,项目名称:MyGalaxy,代码行数:27,代码来源:Ship.cs


示例20: ManipulationDelta

 /// <summary>
 ///     Creates a new instance of this object.
 /// </summary>
 public ManipulationDelta(Vector translation, double rotation, Vector scale, Vector expansion)
 {
     Translation = translation;
     Rotation = rotation;
     Scale = scale;
     Expansion = expansion;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:10,代码来源:ManipulationDelta.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Windows.VisualState类代码示例发布时间:2022-05-26
下一篇:
C# Windows.UIElement类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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