Air_Hockey_Simulator.Physics.Line.IntersectionWith C# (CSharp) Method

IntersectionWith() public method

public IntersectionWith ( Line line ) : PointD
line Line
return PointD
        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);
            }
        }

Same methods

Line::IntersectionWith ( Arc arc ) : Air_Hockey_Simulator.Physics.PointD[]

Usage Example

Beispiel #1
1
 public double DistanceTo(Line line)
 {
     Line perpendicular = line.Perpendicular(this);
     PointD intersection = line.IntersectionWith(perpendicular);
     return DistanceTo(intersection);
 }
All Usage Examples Of Air_Hockey_Simulator.Physics.Line::IntersectionWith