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


C# GeoLib.C2DPoint类代码示例

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


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

示例1: SetMinimum

        /// <summary>
        /// Set to be the minimum bounding circle for the 3 points.
        /// </summary>
        /// <param name="Point1">The first point to include.</param> 
        /// <param name="Point2">The second point to include.</param> 
        /// <param name="Point3">The third point to include.</param> 
	    public void SetMinimum(C2DPoint Point1, C2DPoint Point2, C2DPoint Point3)
        {
            double dDist12 = Point1.Distance(Point2);
            double dDist23 = Point2.Distance(Point3);
            double dDist31 = Point3.Distance(Point1);
            if (dDist12 >= dDist23 && dDist12 >= dDist31)
            {
                SetMinimum(Point1, Point2);
                if (this.Contains(Point3))
                    return;
            }
            else if (dDist23 >= dDist31)
            {
                SetMinimum(Point2, Point3);
                if (this.Contains(Point1))
                    return;
            }
            else
            {
                SetMinimum(Point3, Point1);
                if (this.Contains(Point2))
                    return;
            }

            // If here, the simple minimum of any 2 doesn't incorporate the other 1 so the
            // minimum is the circumscribed circle.
            SetCircumscribed(Point1, Point2, Point3);
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:34,代码来源:C2DCircle.cs

示例2: Update

    // Update is called once per frame
    void Update()
    {
        if (guiController.IsMenu ()) return;

        var screenPos = Camera.main.ScreenToWorldPoint (inputController.GetPosition ());
        var worldPos = new Vector3 (screenPos.x, screenPos.y, -2);

        if (inputController.IsEventStart ()) {
            if (_stone == null) {
                _stone = GameObjectManager.CreateStone (logicController.toPlay, worldPos);
            }
        } else {
            if (_stone != null){
                    _stone.transform.localPosition = worldPos;
                    _stone.GetComponent<StoneView>().Legal = logicController.HasPlace(new C2DPoint(worldPos.x, worldPos.y));

                if (inputController.IsEventEnd ()) {
                    var point = new C2DPoint(_stone.transform.position.x,
                                             _stone.transform.position.y);
                    if (logicController.addStone(point)) {
                        networkController.SendPoint(point);
                        _stone.transform.localPosition = new Vector3(worldPos.x, worldPos.y, 0);
                        _stone.GetComponent<StoneView>().HideBackground();
                        _stone = null;
                    } else {
                        GameObject.Destroy(_stone);
                    }
                }
            }
        }
    }
开发者ID:projektorkraft,项目名称:PiGo,代码行数:32,代码来源:BoardController.cs

示例3: Contains

        /// <summary>
        /// True if the point is in the shape.
        /// </summary> 
        /// <param name="pt">The point to test set.</param> 
	    public bool Contains(C2DPoint pt)
        {
	        if (!BoundingRect.Contains(pt))
		        return false;

	        C2DPointSet IntersectedPts = new C2DPointSet ();

	        C2DLine Ray = new C2DLine(pt, new C2DVector(BoundingRect.Width(), 0.000001)); // Make sure to leave

	        if (!this.Crosses(Ray,  IntersectedPts))
		        return false;
	        else
	        {
		        IntersectedPts.SortByDistance(Ray.point);
		        if ( IntersectedPts[0].PointEqualTo(pt))
		        {
			        // For integers, the pt can start On a line, meaning it's INSIDE, but the ray could cross again
			        // so just return true. Because the equality test is really a test for proximity, this leads to the
			        // possibility that a point could lie just outside the shape but be considered to be inside. This would
			        // only be a problem with very small shapes that are a very long way from the origin. E.g. a 1m2 object
			        // 1 million metres from the origin and a point 0.1mm away from the edge would give rise to a relative 
			        // difference of 0.0001 / 1000000 = 0.000000001 which would just be consider to be inside.
			        return true;
		        }
		        else
		        {
			        // Return true if the ray 
			        return (IntersectedPts.Count & (int)1) > 0;
		        }
	        }

        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:36,代码来源:C2DPolyBase.cs

示例4: C2DArc

        /// <summary>
        /// Contructor.
        /// </summary>
        /// <param name="PtFrom">The point the arc is to go from.</param>
        /// <param name="Vector">The vector defining the end point.</param>
        /// <param name="dRadius">The corresponding circles radius.</param>
        /// <param name="bCentreOnRight">Whether the centre is on the right.</param>
        /// <param name="bArcOnRight">Whether the arc is to the right of the line.</param>
	    public C2DArc(C2DPoint PtFrom, C2DVector Vector, double dRadius, 
		    bool bCentreOnRight, bool bArcOnRight)
        {
            Line.Set(PtFrom, Vector);
            Radius = dRadius;
            CentreOnRight = bCentreOnRight;
            ArcOnRight = bArcOnRight;
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:16,代码来源:C2DArc.cs

示例5: afterMove

 void afterMove(C2DPoint pos, Constants.StoneColor color)
 {
     forbiddenShapes.Add (makeCircle(pos,Constants.stoneSize));
     if (color == Constants.StoneColor.Black) {
         toPlay = Constants.StoneColor.White;
     }
     else {
         toPlay = Constants.StoneColor.Black;
     }
     Debug.Log (blackShape.Count);
     Debug.Log (whiteShape.Count);
 }
开发者ID:projektorkraft,项目名称:PiGo,代码行数:12,代码来源:LogicController.cs

示例6: addStone

 public bool addStone(C2DPoint pos)
 {
     Constants.StoneColor color = toPlay;
     //TODO: copy here
     List<C2DHoledPolyArc> _blackShape = blackShape;
     List<C2DHoledPolyArc> _whiteShape = whiteShape;
     if (HasPlace (pos) && isLegal(pos, color, _blackShape, _whiteShape)) {
         makeMove (pos, color, blackShape, whiteShape);
         afterMove (pos, color);
         return true;
     }
     return false;
 }
开发者ID:projektorkraft,项目名称:PiGo,代码行数:13,代码来源:LogicController.cs

示例7: makeCircle

    C2DHoledPolyArc makeCircle(C2DPoint pos, float radius)
    {
        C2DPolyArc shape = new C2DPolyArc ();

        shape.SetStartPoint (new C2DPoint(pos.x+radius,pos.y));

        for (int i = 0; i < 16; i++) {
            shape.LineTo(new C2DPoint (pos.x + Mathf.Cos(Mathf.PI*2*i/16)*radius, pos.y+ Mathf.Sin(Mathf.PI*2*i/16)*radius), radius, false, true);
        }
        shape.Close (radius, false, true);

        C2DHoledPolyArc result = new C2DHoledPolyArc ();
        result.Rim = shape;
        return result;
    }
开发者ID:projektorkraft,项目名称:PiGo,代码行数:15,代码来源:LogicController.cs

示例8: LineTo

        /// <summary>
        /// Adds a point which is a striaght line from the previous.
        /// </summary>
        /// <param name="Point">The point to go to.</param> 
	    public void LineTo(C2DPoint Point)
        {
	        if (Lines.Count == 0)
		        return;

	        C2DLine pLine = new C2DLine( Lines[Lines.Count - 1].GetPointTo(), Point );

	        if (Lines.Count == 1 && Lines[0] is C2DLine &&
                Lines[0].GetPointTo().PointEqualTo(Lines[0].GetPointFrom()))  // CR 19-1-09
	        {
                Lines[0] = pLine;
	        }
	        else
	        {
                Lines.Add(pLine);
	        }
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:21,代码来源:C2DPolyArc.cs

示例9: makeMove

    void makeMove(C2DPoint pos, Constants.StoneColor color, List<C2DHoledPolyArc> blackShape, List<C2DHoledPolyArc> whiteShape)
    {
        C2DHoledPolyArc stoneShape = makeCircle (pos, 1);

        List<C2DHoledPolyArc> ownShape;
        if (color == Constants.StoneColor.Black) {
            ownShape = blackShape;
        } else {
            ownShape = whiteShape;
        }

        List<C2DHoledPolyArc> shapesToMerge = new List<C2DHoledPolyArc> ();
        foreach (C2DHoledPolyArc poly in ownShape) {
            if (poly.Overlaps(stoneShape)) {
                shapesToMerge.Add(poly);
            }
        }

        merge(stoneShape, shapesToMerge, ownShape);
    }
开发者ID:projektorkraft,项目名称:PiGo,代码行数:20,代码来源:LogicController.cs

示例10: Distance

        /// <summary>
        /// Returns the distance from this to the other line.
        /// </summary>
        /// <param name="Other">The Other line.</param>
        /// <param name="ptOnThis">Output. The closest point on this.</param>
        /// <param name="ptOnOther">Output. The closest point on the other line.</param>
	    public double Distance(C2DLine Other,  C2DPoint ptOnThis ,  C2DPoint ptOnOther) 
        {
            // First, project the other line onto this and if it falls entirely below it or
	        // above it then 1. There is no intersection, 2. This is closest to one end on this line.
	        C2DPoint ptOtherP2 = new C2DPoint(Other.GetPointTo());
	        C2DVector vThisP1OtherP1 = new C2DVector(point, Other.point);
	        C2DVector vThisP1OtherP2 = new C2DVector(point, ptOtherP2);
	        C2DPoint ptThisP2 = new C2DPoint(GetPointTo());

	        double dOtherP1Proj = vThisP1OtherP1.Dot(vector);
	        double dOtherP2Proj = vThisP1OtherP2.Dot(vector);
	        // If they are both less than 0 then the projection falls below the line.
	        if (dOtherP1Proj <= 0 && dOtherP2Proj <= 0)
	        {
			    ptOnThis.Set(point);
		        return Other.Distance(point,  ptOnOther);
	        }
	        // Now modify the projection so it is the length along this line.
	        double dThisLength = GetLength();
	        dOtherP1Proj = dOtherP1Proj / dThisLength;
	        dOtherP2Proj = dOtherP2Proj / dThisLength;
	        // If the projections are both above the line then the second point is closest
	        if (dOtherP1Proj >= dThisLength && dOtherP2Proj >= dThisLength)
	        {
		        ptOnThis.Set(ptThisP2);
		        return Other.Distance( ptThisP2,   ptOnOther);
	        }

	        // This hasn't worked so try the same on the other line.
	        C2DVector vOtherP1ThisP1 = new C2DVector (Other.point, point);
	        C2DVector vOtherP1ThisP2 = new C2DVector(Other.point, ptThisP2);

	        double dThisP1Proj = vOtherP1ThisP1.Dot(Other.vector);
	        double dThisP2Proj = vOtherP1ThisP2.Dot(Other.vector);
	        // If they are both less than 0 then the projection falls below the line.
	        if (dThisP1Proj <= 0 && dThisP2Proj <= 0)
	        {
			    ptOnOther.Set( Other.point);
		        return Distance(Other.point,  ptOnThis);
	        }
	        // Now modify the projection so it is the length along this line.
	        double dOtherLength = Other.GetLength();
	        dThisP1Proj = dThisP1Proj / dOtherLength;
	        dThisP2Proj = dThisP2Proj / dOtherLength;
	        // If the projections are both above the line then the second point is closest
	        if (dThisP1Proj >= dOtherLength && dThisP2Proj >= dOtherLength)
	        {
			    ptOnOther.Set(ptOtherP2);
		        return Distance( ptOtherP2,   ptOnThis);
	        }
	        // Now test for an intersection.
            List<C2DPoint> IntPoint = new List<C2DPoint>();
            bool B1 = true, B2 = true;
            if (this.Crosses(Other,  IntPoint,ref  B1, ref B2, false))
	        {
			    ptOnOther.Set(IntPoint[0]);
			    ptOnThis.Set(IntPoint[0]);
		        return 0;
	        }
	        // Otherwise, there MUST be a point projection on one of the lines otherwise both
	        // lines project on either side of each other which is impossible. 
	        // So find the distances to all these projections and take the minimum.
	        double dDist = 0;
	        double dMinDist = 0;
	        bool bSet = false;


            C2DPoint ptOnThisTemp = new C2DPoint();
            C2DPoint ptOnOtherTemp = new C2DPoint(); 
	        // Is the other lines first point projected on this?
	        if (dOtherP1Proj >= 0 && dOtherP1Proj <= dThisLength)
	        {
		        // If so find the point on this line and get distance to it.
		        double dFactor = dOtherP1Proj / dThisLength;
                ptOnThisTemp.Set(new C2DPoint(point.x + vector.i * dFactor,
								           point.y + vector.j * dFactor) );

                dMinDist = Other.point.Distance(ptOnThisTemp);
		        bSet = true;

			    ptOnOther.Set(Other.point);
                ptOnThis.Set(ptOnThisTemp);
	        }
            // Is the other lines second point projected onto this?
	        if (dOtherP2Proj >= 0 && dOtherP2Proj <= dThisLength)
	        {
		        // If so find the point on this and then the distance. Is it less?
		        double dFactor = dOtherP2Proj / dThisLength;
		        ptOnThisTemp.Set( new C2DPoint(point.x + vector.i * dFactor,
											           point.y + vector.j * dFactor) );

                dDist = ptOtherP2.Distance(ptOnThisTemp);
		        if (!bSet || dDist < dMinDist)
		        {
//.........这里部分代码省略.........
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:101,代码来源:C2DLine.cs

示例11: Join

        /// <summary>
        /// Function to join the 2 lines at the point where they do / would intersect. If they do then
        /// the lines are clipped to remove the smallest part of the line. Returns false if they
        /// cannot be joined.
        /// </summary>
        /// <param name="Other">The other line</param>
        public bool Join(C2DLine Other)
        {
            C2DPoint p1 = point;
            C2DPoint p2 = GetPointTo();

            C2DPoint p3 = Other.point;
            C2DPoint p4 = Other.GetPointTo();

            double Ua = (p4.x - p3.x) * (p1.y - p3.y) - (p4.y - p3.y) * (p1.x - p3.x);
            double Ub = (p2.x - p1.x) * (p1.y - p3.y) - (p2.y - p1.y) * (p1.x - p3.x);

            double dDenominator = (p4.y - p3.y) * (p2.x - p1.x) - (p4.x - p3.x) * (p2.y - p1.y);

            if (dDenominator == 0)
                return false;

            Ua = Ua / dDenominator;
            Ub = Ub / dDenominator;

            C2DPoint IntPt = new C2DPoint(p1.x + Ua * (p2.x - p1.x), p1.y + Ua * (p2.y - p1.y));
            if ( Ua >=0.5)
                this.SetPointTo( IntPt );
            else
                this.SetPointFrom( IntPt );

            if ( Ub >=0.5)
                Other.SetPointTo( IntPt );
            else
                Other.SetPointFrom( IntPt );

            return true;
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:38,代码来源:C2DLine.cs

示例12: OverlapsAbove

        /// <summary>
        /// True if part of this line is above the other. Returns the point 
        /// on this and on the other.
        /// </summary>
        /// <param name="Other"></param>
        /// <param name="dVerticalDistance"></param>
        /// <param name="ptOnThis"></param>
        /// <param name="ptOnOther"></param>
        /// <returns></returns>
        public bool OverlapsAbove(C2DLine Other, ref double dVerticalDistance, 
									        C2DPoint ptOnThis, C2DPoint ptOnOther)
        {
	        // Get the 2 points for both lines
	        C2DPoint OtherTo = new C2DPoint(Other.point.x + Other.vector.i, Other.point.y + Other.vector.j);
	        C2DPoint ThisTo = new C2DPoint(point.x + vector.i, point.y + vector.j);
	        // Make an interval for both in the x plane
	        CInterval iThis = new CInterval( point.x, point.x);
	        iThis.ExpandToInclude( ThisTo.x );

	        CInterval iOther = new CInterval( Other.point.x, Other.point.x);
	        iOther.ExpandToInclude( OtherTo.x );
	        // This is an interval for the overlap between the 2
	        CInterval iOverlap = new CInterval();
	        // If there is an overlap...
	        if (iThis.Overlaps(iOther, iOverlap))
	        {
		        double dThisYMin;
		        double dThisYMax;

		        double dOtherYMin;
		        double dOtherYMax;
		        // If the line is vertical then y at the x min / max can be set to the ends of the line.
		        if (vector.i == 0)
		        {
			        dThisYMin = point.y;
			        dThisYMax = ThisTo.y;
		        }
		        else	// otherwise, caluclate the y values at the interval ends
		        {
			        dThisYMin = GetY(iOverlap.dMin);
			        dThisYMax = GetY(iOverlap.dMax);
		        }
		        // Now do the same for the other line
		        if (Other.vector.i == 0)
		        {
			        dOtherYMin = Other.point.y;
			        dOtherYMax = OtherTo.y;
		        }
		        else
		        {
			        dOtherYMin = Other.GetY(iOverlap.dMin);
			        dOtherYMax = Other.GetY(iOverlap.dMax);
		        }
        		
		        // Now find the distance between the 2 at the ends
		        double dDistMin = dThisYMin - dOtherYMin;
		        double dDistMax = dThisYMax - dOtherYMax;
		        // If they are both > 0 then no intersection
		        if ( (dDistMin > 0) && (dDistMax > 0))
		        {
			        dDistMin = Math.Abs( dDistMin);
                    dDistMax = Math.Abs(dDistMax);
			        // find which one is smallest
			        if ( dDistMin > dDistMax)
			        {	
				        dVerticalDistance = dDistMax;	// distance at the max is smallest
				        ptOnThis.x = iOverlap.dMax;
				        ptOnThis.y = dThisYMax;
				        ptOnOther.x = iOverlap.dMax;
				        ptOnOther.y = dOtherYMax;
			        }
			        else
			        {
				        dVerticalDistance = dDistMin;  // distance at the min is smallest
				        ptOnThis.x = iOverlap.dMin;
				        ptOnThis.y = dThisYMin;
				        ptOnOther.x = iOverlap.dMin;
				        ptOnOther.y = dOtherYMin;
			        }

			        return true;
		        }	
		        else if ( (dDistMin < 0) && (dDistMax < 0)) // This is below.
		        {
			        return false;
		        }
		        else
		        {
			        // find the intersection.
			        dVerticalDistance = 0;
			        C2DPointSet pts = new C2DPointSet();
			        if(this.Crosses(Other, pts))
			        {
				        ptOnThis = pts[0];
				        ptOnOther = ptOnThis;
			        }
			        else
			        {
				        Debug.Assert(false);
			        }
//.........这里部分代码省略.........
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:101,代码来源:C2DLine.cs

示例13: Reflect

        /// <summary>
        /// Point reflection.
        /// </summary>
        /// <param name="Line">The line through which to reflect this.</param>
        public override void Reflect(C2DLine Line)
        {
	        C2DPoint pointTo = new C2DPoint(GetPointTo());
	        point.Reflect(Line);
	        pointTo.Reflect(Line);
	        SetPointTo(pointTo);
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:11,代码来源:C2DLine.cs

示例14: RotateToRight

        /// <summary>
        /// Rotates this to the right about the origin provided.
        /// </summary>
        /// <param name="dAng">The angle through which to rotate.</param>
        /// <param name="Origin">The origin about which to rotate.</param>
        public override void RotateToRight(double dAng, C2DPoint Origin)
        {
        	point.RotateToRight(dAng, Origin);
	        vector.TurnRight(dAng);
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:10,代码来源:C2DLine.cs

示例15: GetMidPoint

        /// <summary>
        /// Gets the mid point on the line.
        /// </summary>
	    public C2DPoint GetMidPoint()
        {
	        C2DPoint Result = new C2DPoint(point.x + vector.i / 2, point.y + vector.j / 2);
	        return Result;
        }
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:8,代码来源:C2DLine.cs


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