JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2061
Number of posts: 5164

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
i need a program that will compute area of various geometrical figures Posted by kolibrothers on 22 Nov 2004 at 9:08 AM
I was wishing if someone could write a program that will compute tha area of various figures. This will prompt the user to select a square,rectangle or a triangle. depending on the user selection. and also the prompt should request for the measures. the script will calculate and display the name and the area. the user will be permitted to enter values with decimal places.

square: A =side*side
rectangle A=lenght*width
triangle A=1/2base*height
Report
Re: i need a program that will compute area of various geometrical fig Posted by Derwentdale on 22 Nov 2004 at 12:16 PM
There is a nice algorith available to calculate the area of a polygon defined by an array of x,y coordinate pairs.
It relies on the idea that the area formed by any pair of points (Xi,Yi) and (Xi+1, Yi+1) and the points projected onto the X-axis is a trapezium, with area = (Xi+1-Xi)*(Yi+Yi+1)/2.
Some trapeziums will have a negative and some a positive area. If you add all the areas traversing clockwise, the total is the area of the polygon. Going anti-clock gives the negative area.


Clive

Report
Re: i need a program that will compute area of various geometrical fig Posted by kolibrothers on 29 Nov 2004 at 7:50 AM
: There is a nice algorith available to calculate the area of a polygon defined by an array of x,y coordinate pairs.
: It relies on the idea that the area formed by any pair of points (Xi,Yi) and (Xi+1, Yi+1) and the points projected onto the X-axis is a trapezium, with area = (Xi+1-Xi)*(Yi+Yi+1)/2.
: Some trapeziums will have a negative and some a positive area. If you add all the areas traversing clockwise, the total is the area of the polygon. Going anti-clock gives the negative area.
:
:
: Clive
:
:

So do you think you can help me out?
Thanks
Report
Re: i need a program that will compute area of various geometrical fig Posted by kolibrothers on 29 Nov 2004 at 8:08 AM
: : There is a nice algorith available to calculate the area of a polygon defined by an array of x,y coordinate pairs.
: : It relies on the idea that the area formed by any pair of points (Xi,Yi) and (Xi+1, Yi+1) and the points projected onto the X-axis is a trapezium, with area = (Xi+1-Xi)*(Yi+Yi+1)/2.
: : Some trapeziums will have a negative and some a positive area. If you add all the areas traversing clockwise, the total is the area of the polygon. Going anti-clock gives the negative area.
: :
: :
: : Clive
: :
: :
:
: So do you think you can help me out?


: Thanks

Just some few code to help me complete the program. Please.
:

Report
Re: i need a program that will compute area of various geometrical fig Posted by Derwentdale on 29 Nov 2004 at 12:09 PM

: : So do you think you can help me out?
:

I thought that I had!
What you seem to be asking is for someone to do it all for you. But, even if willing, you would need to specify where the data (x,y) points are coming from, and what form they would be in. After that it is pretty simple- you just need a function with a loop to tot up the contribution from each pair.
Out of any context, it is difficult (for me at least) to be much more specific.


Clive




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.