469,630 Members | 1,207 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,630 developers. It's quick & easy.

Plotting point around a circle


I am trying to plot a series of shapes in a circular fashion. All shapes
are evenly spaced with lines going between each shape. At present, all
shapes are the same size so I can easily plot the shapes evenly around a
circle. As I add more shapes, I just increase the radius of the circle.

I'm calculating the radius as follows:
Dim m As Single = 20.39285714
Dim x As Single = Me.Flowchart1.Shapes.Count
Dim c As Single = 55.52380952
radius = (m * x) + c

I am then plotting the shapes using the following code:
'get center point
Dim centerPoint As New PointF(Me.Flowchart1.Width / 2,
Me.Flowchart1.Height / 2)
'get 360/shapes.count
Dim angle As New Single
angle = 360 / Me.Flowchart1.Shapes.Count
Dim i As New Integer = 1
For Each tmpShape As Shape In Me.Flowchart1.Shapes.Values
'move shape using ( (angle*i)-angle )
Dim calculatedPoint As New PointF
Dim newPoint As New PointF
calculatedPoint = LocateByAngleInt(centerPoint, ((angle *
i) - angle) - 90, radius)
'adjust the point to accommodate the size of the shape
newPoint = New PointF(calculatedPoint.X - tmpShape.Width /
2, calculatedPoint.Y - tmpShape.Height / 2)
If Me.Flowchart1.Shapes.Contains(i.ToString) Then
CType(Me.Flowchart1.Shapes(i.ToString), Shape).Location
= newPoint
End If
i = i + 1

Here's some helper functions I'm using:
Private Function LocateByAngleInt(ByVal Location As PointF, ByVal
Angle As Single, ByVal Radius As Single) As PointF
Dim objPoint As Drawing.PointF
Dim dblRadians As Double
dblRadians = DegreesToRadians(Angle)
objPoint.X = Location.X + CSng(Radius * Math.Cos(dblRadians))
objPoint.Y = Location.Y + CSng(Radius * Math.Sin(dblRadians))
Return objPoint
End Function

Private Function DegreesToRadians(ByVal Degrees As Single) As Double
Return Degrees * Math.PI / 180
End Function

The easy part about the above solution is that I can simply divide 360 by
the number of shapes I have to give me the spacing between each.

What I want to do is allow for the shapes to be resized vertically and then
adjust the circle as necessary whilst keeping spacing between shapes the
same. I have uploaded some crude diagrams of how I would like this to work.
(http://www.bwbfc.com/math/circle.html) If all the shapes are the same
height then the spacing between the shapes will be equal. When a shapes
height increases as shown in the second diagram, I want all shapes to
shuffle round to accommodate the new height. Therefore, using the concept
of a clock face, shapes nearer 3 and 9 o'clock will take up more of the
circumference whereas shapes nearer 12 and 6 o'clock will take up no more
space should their height increase.

So my question is, how can I calculate the location to plot each shape after
taking into consideration their height and position around the circle?
Again, the distance between all shapes should be the same. I figured it
would be easy to work out how much circumference the lines would take. The
nightmare begins when I start to consider that depending on which point of
the circle a shape falls, dictates how much circumference it requires.

More over, this needs to be fast therefore a linear programming approach
would probably be too expensive.

Is this even possible?!? Please let me know if more information or
explanation is required.

Kind regards, Carl Gilbert
Jan 27 '07 #1
0 3619

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Gerrit Holl | last post: by
7 posts views Thread by Russell E. Owen | last post: by
16 posts views Thread by Niels Jensen | last post: by
14 posts views Thread by amitsoni.1984 | last post: by
1 post views Thread by sravan_reddy001 | last post: by
1 post views Thread by T. Crane | last post: by
3 posts views Thread by illusion.admins | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.