public double DistanceTo(Line line) { Line perpendicular = line.Perpendicular(this); PointD intersection = line.IntersectionWith(perpendicular); return DistanceTo(intersection); }
public double DistanceTo(Line line) { Line perpendicular = line.Perpendicular(this); PointD intersection = line.IntersectionWith(perpendicular); return(DistanceTo(intersection)); }
public static Line ProjectionLine(Puck p, Line reference) { PointD ij = reference.IntersectionWith(reference.Perpendicular(p.Location)); double dist = p.Location.DistanceTo(ij); double scale = p.Radius / dist; PointD projection_line_point = ij.Offset((p.Location.X - ij.X) * scale, (p.Location.Y - ij.Y) * scale); return(reference.Parallel(projection_line_point)); }
public PointD IntersectionWith(Line line) { if (this.Slope == line.Slope) return null; else if (this.Slope == null) { return new PointD(Point.X, line.Y(Point.X).Value); } else if (line.Slope == null) { return line.IntersectionWith(this); } else { double x = (this.Point.Y + (double)line.Slope * line.Point.X - (double)this.Slope * this.Point.X - line.Point.Y) / ((double)line.Slope - (double)this.Slope); double y = (double)this.Slope * (x - this.Point.X) + this.Point.Y; //Basically just Y(x) return new PointD(x, y); } }
public frmMain() { InitializeComponent(); Update = Output; //Used to support calling Output() from a different thread. Angle angle = new Angle(60, AngleType.Degrees); Line line = new Line(new PointD(0, 0), angle); Arc arc = new Arc(new PointD(0, 0), 2); PointD[] intersections = line.IntersectionWith(arc); foreach (var point in intersections) { Output(point.ToString()); } //tm.Interval = 1000 * 1000; //tm.MicroTimerElapsed += Tm_MicroTimerElapsed; //tm.Start(); }
public PointD IntersectionWith(Line line) { if (this.Slope == line.Slope) { return(null); } else if (this.Slope == null) { return(new PointD(Point.X, line.Y(Point.X).Value)); } else if (line.Slope == null) { return(line.IntersectionWith(this)); } else { double x = (this.Point.Y + (double)line.Slope * line.Point.X - (double)this.Slope * this.Point.X - line.Point.Y) / ((double)line.Slope - (double)this.Slope); double y = (double)this.Slope * (x - this.Point.X) + this.Point.Y; //Basically just Y(x) return(new PointD(x, y)); } }
public static Line ProjectionLine(Puck p, Line reference) { PointD ij = reference.IntersectionWith(reference.Perpendicular(p.Location)); double dist = p.Location.DistanceTo(ij); double scale = p.Radius / dist; PointD projection_line_point = ij.Offset((p.Location.X - ij.X) * scale, (p.Location.Y - ij.Y) * scale); return reference.Parallel(projection_line_point); }