I am working on a Geometric shapes project (using assembly language). I have a text file contain the coordinates of the line that are intersected at some points . through these intersections I should recognize the shape if it is a rectangle or square or triangle and print out the number of rectangles in this file of coordinates and the number of triangles and the number of square .
for triangle : I should have 3 intersections for rectangle and square : I should have 4 intersections then I should check for the distance is the 4 side are equal in length so its square else its a rectangle
I stored the data of the file in an array of struct this struct called line and contain 4 variable x1,y1,x2,y2
now I have the struct filled with the right data
My own main problem is calculating intersection between the lines What should I do to solve this problem ? I need it coded please
;;;;;;;;;;; DECLARING STRUCT ;;;;;;;;;;
line struct
x1 byte ?
y1 byte ?
x2 byte ?
y2 byte ?
line ends
// that's the function for storing tha numbers in an array of struct
// the array final deals with the part of code that I read from the file
// with and contain the values but reversed so when i fill my array of
// type line I reverse the array final
Store PROC
mov ebx, offset final
add ebx,count1
mov edx, offset array_of_lines
mov ecx,10
l_struct:
mov al, [ebx]
mov (line ptr [edx]).x1 , al
dec ebx
mov al, [ebx]
mov (line ptr [edx]).y1 , al
dec ebx
mov al, [ebx]
mov (line ptr [edx]).x2 , al
dec ebx
mov al, [ebx]
mov (line ptr [edx]).y2 , al
dec ebx
add edx, sizeof line
loop l_struct
that's the text file that I have been given to know how mush rectangles in it squares and triangles
20 20 30 50
10 10 50 50
10 10 30 50
20 20 40 20
40 20 30 50
40 20 40 60
40 60 100 60
100 50 105 50
100 60 100 20
100 20 40 20
*
Now I need to know a simple way to find the intersection and to handle all the cases also ..