473,395 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Plotting point around a circle

Hi

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
Next

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 3770

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Gerrit Holl | last post by:
Hi, I have a dictionairy containing DateTime objects as keys and integers as values. What would be the easiest way to create a simple plot of these, with a number axis versus a time axis? What...
7
by: Russell E. Owen | last post by:
Can anyone recommend a fast cross-platform plotting package for 2-D plots? Our situation: We are driving an instrument that outputs data at 20Hz. Control is via an existing Tkinter application...
10
by: Bhan | last post by:
Using Ptr of derived class to point to base class and viceversa class base { .... } class derived : public base { .... }
12
by: Russ | last post by:
I'm interested in setting up a web page where live data can be displayed in real-time on the web page. For example: I would like to display a (nice looking) graph of some data value versus time...
16
by: Niels Jensen | last post by:
I have been developing a little project which draw's a hexgrid on a panel within a form similar to this - it:s used as a client from a e-mail based strategy game: ____ ____ / \...
14
by: amitsoni.1984 | last post by:
hi, I have some values(say from -a to a) stored in a vector and I want to plot a histogram for those values. How can I get it done in python. I have installed and imported the Matplotlib package...
1
by: sravan_reddy001 | last post by:
I am creating an analog clock. so i hav to draw the line from center to a point in the circle. How can i get the co-ordinates of the points on the circle i fmention the radius and the center of the...
1
by: T. Crane | last post by:
Hi, I am looking for a good plotting library. I intend to do 3D surface plots, 2D contour, 3D waterfall, etc. Right now I have access to National Instruments' Measurement Studio, and it's...
3
by: illusion.admins | last post by:
I am trying to code something to tell me if a selected point is in a particular ellipse. For the ellipse I know how it was constructed (know the x,y, and width, height). But if I just check to see...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.