Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Plotting a circle with system.drawing including rotated labels

I am trying to use system.drawing to draw a circle divided into a variable amount of points, with a text label at each of the points, preferably at an angle matching the current point on the circle (so the labels 'fan out' from the center).

Before I attempt to try and stitch this into my database backend, the first thing I'm trying to do is simply draw the circle as a series of connected points. Something along these lines

for t = 1 to 360 step 10
      x = cos(t)
      y = sin(t)
      pts(cpt) = New Point(x,y)
next
g.DrawCurve(New Pen(Color.Red), pts, 0.8F)

Although obviously with a bit more too it than that. However, I don't think my maths is quite up to the task, and the above method doesn't take into account the labels, so probably isn't the way to go anyway.

I should make it clear I'm not just trying to draw a circle - I'm trying to plot points and arrange them in a circle, if that makes sense.

Been searching Google, but can't really find anything about drawing a circle from scratch.
0
pixuk
Asked:
pixuk
  • 5
  • 2
1 Solution
 
zip001Commented:
Point is for integer points only. You need PointF

You can do a debug.print(pts(cpt).x & " " & pts(cpt).y) to verify that
0
 
pixukAuthor Commented:
Thanks for the tip, but to be honest, at this stage I'm not actually that bothered about the accuracy of the point position - the first thing I need to do is draw a circle, and the snippet above didn't seem to do the trick.

Just to re-iterate the question; I want to draw a circle, and at a variable number of points around it, put text labels at an angle equivalent to that point on the circle.
0
 
zip001Commented:
yes, but the problem is 0<cos(x) <1, so putting it in a Point object will force it to round off to 0 or 1

How about you put 100cos(x) into the point?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pixukAuthor Commented:
I see what your saying. Do you have an example of code which draws a circle using PointF?

Do you know how to draw text at an angle?, assuming, of course, I can get that far!
0
 
zip001Commented:
PointF, just exactly the same as what you are doing :)

Just declare PointF instead of Point

Also, I think multiplying your co-ordinates will help, otherwise your circle will be too small??

Ummm.... drawing text at an angle
I would try drawing text on a Bitmap first, then apply a transform filter to it. Try googling for "rotating an image with VB.Net"
0
 
zip001Commented:
This is good...

http://www.vb-helper.com/howto_net_image_rotate.html

Instead of using a picture box as your input, declare a bitmap, and draw your text to it, then rotate
0
 
zip001Commented:
Thanks, I think it's a bit mean to give a C though... I did answer the original question
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now