A
andrew.butt
Hello, I am a new programmer and am faced with a problem which I am not
totally sure how to start. The problem is as follows:
====================================================
Using recursion, compute the area of a polygone. Cut off a triangle
and use the fact that a triangle with corners (x1,y1), (x2,y2), (x3,
y3) has
area = |(x1)(y2) + (x2)(y2) + (x3)(y1) - (y1)(x2) - (y2x3) - (y3x1)|/2
The program will be testerd by redirecting a text file to its standard
input. Such a file represent a polygone. Within a file, each line
contains two (non-scientific notation) floating point number to
indicate the corrdinates of a vertex.
====================================================
My major problem is that I have not totally developed the recursive
thought that it involves, I can visualize doing this non-recursively
quite easily, so if anyone could offer any advice on how a recursive
approach to this would be started I would be very greatful.
Thanks.
totally sure how to start. The problem is as follows:
====================================================
Using recursion, compute the area of a polygone. Cut off a triangle
and use the fact that a triangle with corners (x1,y1), (x2,y2), (x3,
y3) has
area = |(x1)(y2) + (x2)(y2) + (x3)(y1) - (y1)(x2) - (y2x3) - (y3x1)|/2
The program will be testerd by redirecting a text file to its standard
input. Such a file represent a polygone. Within a file, each line
contains two (non-scientific notation) floating point number to
indicate the corrdinates of a vertex.
====================================================
My major problem is that I have not totally developed the recursive
thought that it involves, I can visualize doing this non-recursively
quite easily, so if anyone could offer any advice on how a recursive
approach to this would be started I would be very greatful.
Thanks.