Solved

Calculate the radius of a n-sided polygon such that the area of the polygon matches the area of a circle with the same radius.

Posted on 2011-02-15
6
1,470 Views
Last Modified: 2012-08-13
Hi.

I know I should be able to do this, but I'm old and I've forgotten.

The issue is that SQL Server 2008 doesn't support a circle in its geospatial data type (as far as I can tell - still waiting on my Dev Ed).

So, I need to create an n-sided polygon that covers the same area as a circle of the same radius.

I'm using Google Maps to show this to TPTB within the company (I'm on a learning exercise, so having a LOT of fun).

Currently, I have the following code:
		fn_makePolygon = function(map, polygon, i_Points, i_Radius)
			{
			// Using the geometry library, calculate an array of points for the polygon
			var a_Path = [];
			var ll_Centre = map.getCenter();
			var f_Angle = 360 / i_Points;
			var f_Distance = i_Radius * 1609.344; // Meters to miles conversion.
			
			for(var i_Point = 0 ; i_Point <= i_Points ; ++i_Point)
				{
				a_Path.push
					(
					google.maps.geometry.spherical.computeOffset
						(
						ll_Centre,
						f_Distance,
						i_Point * f_Angle
						)
					);
				}
			polygon.setPath(a_Path);
			}

Open in new window


This creates an n-sided closed polygon whose points lie on a circle of the same radius - you can see this in action at n-sided polygon fits inside circle.

What I would like is actually 2 fold.

1 - To calculate the path of an n-sided polygon so that the circle fits inside the polygon (just like the existing polygon fits inside the circle)
2 - To calculate the path of an n-sided polygon so that the area of the circle and the polygon are the same.


Don't worry about the coding, if you have issues with that, just the maths required will be enough for me.

I'm guessing that all I really need is to adjust the meters/miles conversion as this is all that actually alters the side the polygon.


Regards,

Richard Quadling.

P.S. I'm using Google Chrome V10, so the sliders are not going to be visible in older browsers - simply enter the number and tab off the input seems to work OK for IE/FF. This is just a test script, so not an important issue.
0
Comment
Question by:Richard Quadling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 18

Assisted Solution

by:deighton
deighton earned 100 total points
ID: 34896755
surely for a given radius, all circles and polygons have different areas

the area of a regular n-gon with distance from centre to vertex x  is

nx^2 sin (360 / 2n) cos(360 /2n)

so if you had a circle radius R, the radius r of an n-gon with the same area would be

nr^2 sin (360 / 2n) cos(360 /2n) = pi R^2

r = sqrt(pi R^2 / [nsin (360 / 2n) cos(360 /2n) ])
0
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 400 total points
ID: 34897431
Note: since your code uses degrees, not radians, so am I. If you get really weird results, change all the 360s and 180s to 2pi and pi.

Given a circumradius c (distance from center to vertex) the area is
nc^2sin(360/n)/2
So if the circle's area is A then you want to make your vertices
sqrt(2A/nsin(360/n))
from the center.

To circumscribe the polygon around the circle, you want the apothem a (distance from center to closest point on edge) to be the same as the radius of the circle so you want the vertices to be
r sec(180/n)
from the center (where r is the radius of the circle and sec(180/n)=1/cos(180/n)
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34897449
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34897478
Here is where I got the other one (outer radius to area)
http://www.mathopenref.com/polygonregulararea.html
0
 
LVL 40

Author Comment

by:Richard Quadling
ID: 34899901
Excellent. I'll be incorporating the logic tomorrow and get back to you then.
0
 
LVL 40

Author Comment

by:Richard Quadling
ID: 34905498
Thanks for all of this.

I've got the following formula working ...


polygon_radius = sqrt( (pi * circle_radius^2 * 2) / (polygon_sides * SIN(360/polygon_sides) )

and in Javascript ...

var f_Distance = 1609.344 * Math.sqrt( (2 * Math.PI * i_Radius * i_Radius) / (i_Points * Math.sin(2 * Math.PI / i_Points) ) );

as Google Maps wants the value in meters and my users think in miles (as do the drivers).

Thank you all. Extremely useful comments.

Richard.



0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question