Air_Hockey_Simulator.Physics.Physics.ProjectionLine C# (CSharp) Method

ProjectionLine() public static method

public static ProjectionLine ( Puck p, Line reference ) : Line
p Puck
reference Line
return Line
        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);
        }