Question:

Draw Perpendicular Line at 90 Degree?

by Guest32276  |  earlier

0 LIKES UnLike

Hi all.

Looking for example code in Visual Basic from you experts to draw a line perpendicular to the existing line at 90 degree.

(Line to be drawn)

|

|

|

|

-----------------------------( Given Line )

I hope that I can hear from you soon. Please note that the method has to work with lines of different slopes. Angle is measured in Degrees.

Regards

 Tags:

   Report

2 ANSWERS


  1. Gopinath has the math correct however it will not work in that format completely. Also Visual Basic defaults to Radians so more math will have to be done to convert to degrees (not to difficult).

    You will have to tell VB where on the form or picturebox you need to display and using negative values will put your result (or at least part of it) off the area you are drawing to so you will need to convert your answer to match the drawing area.

    If you are good with VB you can knock this out in a couple of evenings.

    : )


  2. i dont know vb...

    but little maths could be of some use.....

    y-y1=m(x-x1)

    this is the equation of a line.

    y1 and x1 are one points.

    m is the slope.  tan theta could give u.....

    first find the slope of the given line, m1=(y2-y1)/(x2-x1) will do.

    where x1,y1 and x2,y2 are two points on it...

    then for two lines to be perpendicular, m1m2=-1, therefore the slope m of the new line is, -1/m1. With the point on the given line on which the new line is perpendicular, we can form the line equation with y-y1=m(x-x1)

    where x1,y1 is the point(point of intersection)

    With the equation of the line, find two points and complete the line....

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.