Sign in to follow this  
Followers 0
greenmachine

Line drawer and intersection calculator

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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)

Share this post


Link to post
Share on other sites

OP is offline since 6 years. Do you think he/she will read this?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

There's a chance if the OP has email notification turned on, as adolfitos reply was the first :D

But yea, necro'ing it is :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0