473,669 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.S hapes.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.Flowc hart1.Width / 2,
Me.Flowchart1.H eight / 2)
'get 360/shapes.count
Dim angle As New Single
angle = 360 / Me.Flowchart1.S hapes.Count
Dim i As New Integer = 1
For Each tmpShape As Shape In Me.Flowchart1.S hapes.Values
'move shape using ( (angle*i)-angle )
Dim calculatedPoint As New PointF
Dim newPoint As New PointF
calculatedPoint = LocateByAngleIn t(centerPoint, ((angle *
i) - angle) - 90, radius)
'adjust the point to accommodate the size of the shape
newPoint = New PointF(calculat edPoint.X - tmpShape.Width /
2, calculatedPoint .Y - tmpShape.Height / 2)
If Me.Flowchart1.S hapes.Contains( i.ToString) Then
CType(Me.Flowch art1.Shapes(i.T oString), Shape).Location
= newPoint
End If
i = i + 1
Next

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

Private Function DegreesToRadian s(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 3788

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

Similar topics

6
4451
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 library is the most suitable for this? 'plot' on parnassus yields 18 hits, but since I have zero experience, I don't know where to start. What makes it difficult is that I have a time axis instead of a simple integer x-axis. Gnuplot doesn't seem...
7
3068
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 (which is being extended for this new instrument) that runs on unix, mac and windows. We wish to update 5-10 summary plots at approximately 2 Hz and will be offering controls to control the instrument and the plots, preferably (but not...
10
3318
by: Bhan | last post by:
Using Ptr of derived class to point to base class and viceversa class base { .... } class derived : public base { .... }
12
6545
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 and have the graph update every second without the user having to do anything like hit a refresh button. The data to plot is readily available from an application running on the server - I can expose it in whatever way is needed (currently easily...
16
1953
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: ____ ____ / \ / \ / (0,0) \____/ (2,0) \____/ \ / \ / \ \____/(1,1) \____/ (3,1) \_ / \ / \ / (0,1) \____/ (2,1) \____/
14
6745
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 but on executing the code =hist(eig, 10) # make a histogram I am getting an error saying "NameError: name 'hist' is not defined". Is there any other way to plot histograms over a given range?
1
1720
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 circle.
1
7063
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 supposed to provide some plotting classes, but I've never used it. Does anyone have any experience with NI's Meas. Studio? Can someone suggest a good plotting library that I might want to use instead of Meas. Studio? Is there a community standard?
3
9798
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 if the point is in the rectangle making up the ellipse wouldn't that possibly give me a false answer? Eg if the point is the upper left coordinate of the rectangle...this point is in the rectangle making up ellipse but NOT the ellipse itself. ...
0
8466
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8896
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8810
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6211
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2798
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.