static public bool IsIntersecting(this Plane2 item, Ray2 ray, out Vector2 point) { float distance; bool did_intersect = item.IsIntersecting(ray, out distance); point = ray.GetPointAlong(distance); return(did_intersect); }
static public bool IsIntersecting(this Plane2 item, LineSegment2 line_segment, out Vector2 point) { float distance; bool did_intersect = item.IsIntersecting(line_segment, out distance); point = line_segment.GetPointOnByDistance(distance); return(did_intersect); }
static public bool IsInside(this Plane2 item, Vector2 point, float tolerance = 0.0f) { if (item.IsOutside(point, tolerance) == false) { return(true); } return(false); }
static public bool IsOutside(this Plane2 item, Vector2 point, float tolerance = 0.0f) { if (item.GetSignedDistanceToPoint(point) > tolerance) { return(true); } return(false); }
static public bool IsIntersecting(this Plane2 item, Ray2 ray, out float distance) { if (item.IsIntersectingLine(ray, out distance) && distance >= 0.0f) { return(true); } return(false); }
static public Plane2 CreatePointsAndInsidePoint(Vector2 v0, Vector2 v1, Vector2 inside) { Plane2 plane = CreatePoints(v0, v1); if (plane.IsInside(inside)) { return(plane); } return(plane.GetFlipped()); }
static public bool IsIntersecting(this Plane2 item, LineSegment2 line_segment, out float distance) { if (item.IsIntersecting(line_segment.GetRay(), out distance)) { if (distance <= line_segment.GetLength()) { return(true); } } return(false); }
static public bool IsIntersecting(this Plane2 item, Triangle2 triangle, out LineSegment2 output) { Vector2 v0; Vector2 v1; if (triangle.GetEdges() .TryConvert((LineSegment2 e, out Vector2 v) => item.IsIntersecting(e, out v)) .PartOut(out v0, out v1) == 2) { output = new LineSegment2(v0, v1); return(true); } output = default(LineSegment2); return(false); }
static public bool IsIntersecting(this PlaneSpace item, Plane plane, out Plane2 output) { Ray ray; if (item.plane.IsIntersecting(plane, out ray)) { output = Plane2Extensions.CreatePointsAndInsidePoint( item.ProjectPoint(ray.origin), item.ProjectPoint(ray.origin + ray.direction), item.ProjectPoint(ray.origin - plane.normal) ); return(true); } output = default(Plane2); return(false); }
static public ConvexPolygon GetIntersection(this ConvexPolygon item, Plane2 plane) { ConvexPolygon intersection = new ConvexPolygon(); intersection.AddVertexs(item.GetVertexs().Narrow(v => plane.IsInside(v))); Vector2 point; foreach (Face face in item.GetFaces()) { if (face.IsIntersecting(plane, out point)) { intersection.AddVertex(point); } } return(intersection); }
static public bool IsIntersecting(this Face item, Plane2 plane, out float distance) { return(plane.IsIntersecting(item.GetLineSegment(), out distance)); }
static public Vector2 GetOrigin(this Plane2 item) { return(item.normal * -item.distance); }
static public float GetAbsoluteDistanceToPoint(this Plane2 item, Vector2 point) { return(item.GetSignedDistanceToPoint(point).GetAbs()); }
static public float GetSignedDistanceToPoint(this Plane2 item, Vector2 point) { return(item.normal.GetDot(point - item.GetOrigin())); }
static public Vector2 ProjectPoint(this Plane2 item, Vector2 point) { return(point - item.normal * item.GetSignedDistanceToPoint(point)); }
static public bool IsIntersecting(this Face item, Plane2 plane, out Vector2 point) { return(plane.IsIntersecting(item.GetLineSegment(), out point)); }
static public bool IsIntersectingLine(this Plane2 item, Ray2 ray, out float distance) { return(ray.IsIntersectingLine(item.GetOrigin(), item.normal, out distance)); }
static public Plane2 GetFlipped(this Plane2 item) { return(Plane2Extensions.CreateNormalAndPoint(-item.normal, item.GetOrigin())); }