private bool ValidateAngles(Pnt dir, [CanBeNull] SignedHullLineArc arc) { double angle = Math.Atan2(dir.Y, dir.X); if (!IsInArcAngle(angle)) { return(false); } if (arc != null) { double arcAngle = angle + (arc.Deflate ? 0 : Math.PI); if (!IsInArcAngle(arcAngle, arc.Arc.StartDirection, arc.Arc.Angle)) { return(false); } } return(true); }
private bool CutLineThis(Pnt p0, Pnt l0, ref double tMin, ref double tMax, SignedHullLineArc arc = null) { double r = _radius + (arc?.Radius ?? 0); double tCircleMin; double tCircleMax; if (!SegmentUtils.CutLineCircle( p0, l0, _center, r * r, out tCircleMin, out tCircleMax)) { return(false); } var cuts = false; double f = r > 0 ? 1 : -1; Pnt dirMin = p0 + tCircleMin * l0 - _center; if (ValidateAngles(f * dirMin, arc)) { cuts = true; tMin = Math.Min(tMin, tCircleMin); tMax = Math.Max(tMax, tCircleMin); } Pnt dirMax = p0 + tCircleMax * l0 - _center; if (ValidateAngles(f * dirMax, arc)) { cuts = true; tMin = Math.Min(tMin, tCircleMax); tMax = Math.Max(tMax, tCircleMax); } return(cuts); }