Polygon.V2 C# (CSharp) Method

V2() public static method

public static V2 ( Vector3 v ) : Vector2D,
v Vector3
return Vector2D,
    public static Vector2D V2(Vector3 v)
    {
        return new Vector2D(v.x, v.z);
    }

Same methods

Polygon::V2 ( Vector3D, v ) : Vector2D,

Usage Example

Beispiel #1
0
 public bool IsPointInside(Vector2 point)
 {
     Vector2D[] farFarAwayPoints = new Vector2D[] {
         new Vector2D(point) + new Vector2D(99999, 99998),
         new Vector2D(point) + new Vector2D(-99999, 89990),
     };
     LineSegment2D[] lineSegments = new LineSegment2D[] {
         new LineSegment2D(new Vector2D(point), farFarAwayPoints[0]),
         new LineSegment2D(new Vector2D(point), farFarAwayPoints[1]),
     };
     foreach (var ls in lineSegments)
     {
         int hits = 0;
         for (int i = 0; i < vertices.Count; i++)
         {
             LineSegment2D l1  = new LineSegment2D(Polygon.V2(vertices[i]), Polygon.V2(vertices[(i + 1) % vertices.Count]));
             Vector2D      res = Vector2D.zero;
             if (ls.LineIntersect(l1, out res))
             {
                 hits++;
             }
         }
         if (hits % 2 == 1)
         {
             return(true);
         }
     }
     return(false);
 }