public static bool IsRayInsectCircle3(Vector3 rayOrigin, Vector3 rayDirection, Vector3 center, float r, GeoPlane plane, ref GeoInsectPointInfo insect) { if (GeoPlaneUtils.IsPlaneInsectRay(plane.mNormal, plane.mD, rayOrigin, rayDirection, ref insect)) { if (GeoCircleUtils.IsInSphere(center, r, insect.mHitGlobalPoint)) { return(true); } } return(false); }
public static bool IsSegmentInsectCircle3(Vector3 seg1, Vector3 seg2, Vector3 center, float r, GeoPlane plane, ref GeoInsectPointInfo insect) { bool isInsect = GeoPlaneUtils.IsPlaneInsectSegment(plane.mNormal, plane.mD, seg1, seg2, ref insect); if (isInsect) { if (GeoCircleUtils.IsInSphere(center, r, insect.mHitGlobalPoint)) { return(true); } } insect.mIsIntersect = isInsect; return(isInsect); }
public static bool IsTriangleInsectCircle3(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 center, float r, GeoPlane plane, ref GeoInsectPointArrayInfo insect) { bool isInsect = GeoPlaneUtils.IsPlaneInsectTriangle(plane.mNormal, plane.mD, p1, p2, p3, ref insect); if (isInsect) { if (insect.mHitGlobalPoint.mPointArray.Count == 3) // 共面, 转化成 2d { insect.Clear(); return(IsTriangleInsectPlaneCircle2(p1, p2, p3, center, r, plane, ref insect)); } else if (insect.mHitGlobalPoint.mPointArray.Count == 1) { if (GeoCircleUtils.IsInSphere(center, r, insect.mHitGlobalPoint.mPointArray[0])) { return(true); } } else if (insect.mHitGlobalPoint.mPointArray.Count == 2) { Vector3 seg1 = plane.TransformToLocal(insect.mHitGlobalPoint.mPointArray[0]); Vector3 seg2 = plane.TransformToLocal(insect.mHitGlobalPoint.mPointArray[1]); Vector3 c1 = plane.TransformToLocal(center); Vector2 p12 = new Vector2(seg1.x, seg1.z); Vector2 p22 = new Vector2(seg2.x, seg2.z); Vector2 c2 = new Vector2(c1.x, c1.z); insect.Clear(); GeoInsectPointArrayInfo temp = new GeoInsectPointArrayInfo(); if (GeoSegmentUtils.IsSegmentInsectCircle2(p12, p22, c2, r, ref temp)) { insect.mIsIntersect = true; foreach (Vector3 v in temp.mHitGlobalPoint.mPointArray) { Vector3 vv = new Vector3(v.x, 0.0f, v.y); vv = plane.TransformToGlobal(vv); insect.mHitGlobalPoint.mPointArray.Add(vv); } return(true); } } } return(false); }
public static bool IsLineInsectCircle3(Vector3 line1, Vector3 line2, Vector3 center, float r, GeoPlane plane, ref GeoInsectPointArrayInfo insect) { if (GeoPlaneUtils.IsPointOnPlane(plane.mNormal, plane.mD, line1) && GeoPlaneUtils.IsPointOnPlane(plane.mNormal, plane.mD, line2)) { return(IsLineInsectCirclePlane2(line1, line2, center, r, plane, ref insect)); } GeoInsectPointInfo info = new GeoInsectPointInfo(); bool isInsect = GeoPlaneUtils.IsPlaneInsectLine(plane.mNormal, plane.mD, line1, line2, ref info); if (isInsect) { if (GeoCircleUtils.IsInSphere(center, r, info.mHitGlobalPoint)) { insect.mIsIntersect = true; insect.mHitGlobalPoint.mPointArray.Add(info.mHitGlobalPoint); return(true); } insect.mIsIntersect = false; } return(false); }