Jump to content

Line drawer and intersection calculator


greenmachine
 Share

Recommended Posts

My friend was programming a similar program in Java last year, and since then I've always wanted to try it for myself. I never got good enough at Java to do it, so once I found AutoIt I decided to try it. I finally got around to it again, and this is the result.

It starts off with two random line segments, colored red and blue to distinguish them from the black axes, and tells if the segments intersect or not. If they are parallel (which is unlikely, as all the points are randomly generated), it tells that in the label. If they do not intersect, it tells that too. And if they do intersect, it tells the intersection point in pixels (each grid line is 10 pixels from the center).

The "Refresh Lines" button randomly generates two more lines, overwriting the previous two. The "Find Intersection" button gives much more information than the label: it tells all the points of the lines as well as the intersection point. If the two line segments are not intersecting, this message box will tell the intersection point if the two segments were extended into their full lines (always fun to play around with).

This picture shows the main window with lines and intersection point label.

Drawing3.au3

Note: this requires the beta version of AutoIt (I used 3.1.1.76), as the graphic controls are new.

Edit -

One more thing: I don't really know if it bothers anyone else, but it has to refresh a lot to make all the changes, and does a lot of flashing onscreen (lots of stuff to refresh). If there's any way to fix that, that'd be cool. Also, it might be processor-intensive, as I am constantly running a function to check intersections and update the label during my onevent loop. It didn't seem to bother me, as my computer is always running at 100% due to other programs going on in the background. Just a heads-up.

Edited by greenmachine
Link to comment
Share on other sites

  • 8 years later...

Thanks a lot for you .au3. I was trying to create something similar (I want to measure the angles between the lines) and your code is going to save me a lot of work.

 

(I know that this thread is from 2005, just wanted to say thanks if the OP reads it)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...