/// <summary> /// Constructs a line passing through <paramref name="location"/> with the provided <paramref name="direction"/> clipped by the /// rectangle <paramref name="clippedBy"/> /// </summary> /// <param name="location">Point on the (extension of the) line </param> /// <param name="direction">Direction of the line</param> /// <param name="clippedBy">Clipping rectangle</param> public Line2D(GeoPoint2D location, GeoVector2D direction, BoundingRect clippedBy) { direction.Norm(); // ist ja ne Kopie // das geht aber eleganter, oder? GeoPoint2D c = Geometry.DropPL(clippedBy.GetCenter(), location, direction); double l = clippedBy.Width + clippedBy.Height; startPoint = c + l * direction; endPoint = c - l * direction; ClipRect clr = new ClipRect(ref clippedBy); clr.ClipLine(ref startPoint, ref endPoint); }
public override ICurve2D[] GetTangentCurves(GeoVector direction, double umin, double umax, double vmin, double vmax) { if (Precision.SameDirection(direction, zAxis, false)) { return(new ICurve2D[0]); } GeoPoint2D uv = PositionOf(location + zAxis + (direction ^ zAxis)); GeoVector2D dir2d = uv.ToVector(); dir2d.Length = Math.Max(Math.Max(Math.Abs(umax), Math.Abs(umin)), Math.Max(Math.Abs(vmax), Math.Abs(vmin))) * 1.1; ClipRect clr = new ClipRect(umin, umax, vmin, vmax); GeoPoint2D sp = GeoPoint2D.Origin - dir2d; GeoPoint2D ep = GeoPoint2D.Origin + dir2d; if (clr.ClipLine(ref sp, ref ep)) { return new ICurve2D[] { new Line2D(sp, ep) } } ; else { return(new ICurve2D[0]); } }