public static bool Is2DPointOnBorder(Vector2 point, Vector2 quadCenter, float quadWidth, float quadHeight, Vector2 quadRight, Vector2 quadUp, QuadEpsilon epsilon = new QuadEpsilon()) { var segmentEps = new SegmentEpsilon(); segmentEps.PtOnSegmentEps = epsilon.WireEps; var corners = Calc2DQuadCornerPoints(quadCenter, new Vector2(quadWidth, quadHeight), quadRight, quadUp); for (int ptIndex = 0; ptIndex < corners.Count; ++ptIndex) { Vector2 startPt = corners[ptIndex]; Vector2 endPt = corners[(ptIndex + 1) % corners.Count]; if (SegmentMath.Is2DPointOnSegment(point, startPt, endPt, segmentEps)) { return(true); } } return(false); }
public static bool Raycast(Ray ray, out float t, Vector3 startPoint, Vector3 endPoint, SegmentEpsilon epsilon = new SegmentEpsilon()) { if (CylinderMath.Raycast(ray, out t, startPoint, endPoint, epsilon.RaycastEps)) { return(true); } if (SphereMath.Raycast(ray, out t, startPoint, epsilon.RaycastEps)) { return(true); } return(SphereMath.Raycast(ray, out t, endPoint, epsilon.RaycastEps)); }
public static bool Is2DPointOnSegment(Vector2 point, Vector2 startPoint, Vector2 endPoint, SegmentEpsilon epsilon = new SegmentEpsilon()) { float pointDistToSegment = point.GetDistanceToSegment(startPoint, endPoint); return(pointDistToSegment <= epsilon.PtOnSegmentEps); }