コード例 #1
0
        //
        // Return the line perpendicular to this segment at the given point.
        // The point is ON the segment.
        public Segment GetPerpendicularByLength(Point pt, double length)
        {
            Segment perp = this.GetPerpendicular(pt);

            //
            // Find the point which is length distance from the given point.
            //
            // Treat the given perpendicular as a vector; normalize and then multiply.
            //
            Point vector = Point.MakeVector(perp.Point1, perp.Point2);

            vector = Point.Normalize(vector);
            vector = Point.ScalarMultiply(vector, length);

            // 'Move' the vector to begin at its starting point: pt
            // Return the perpendicular of proper length.
            return(new Segment(pt, new Point("", pt.X + vector.X, pt.Y + vector.Y)));
        }