|
-
Jan 8th, 2013, 05:29 AM
#1
Thread Starter
Junior Member
-
Jan 9th, 2013, 06:37 AM
#2
Thread Starter
Junior Member
-
Jan 9th, 2013, 09:43 AM
#3
Thread Starter
Junior Member
Re: Dividing a circle
Rrrright... I spoke too soon. I don't mean to be annoying, but I have another problem now. I've created most of the stimuli as I wanted, but there seems to be something wrong. I've uploaded a picture in combination to the code. The small circles within the 'doughnut' shape should be equally spaced from each other and should be centred on the outline of the green circle. However, as it appears obvious from the image - this is not the case. The bottom and top two are not centred where they should be. Also, they are not really equally spaced
Is there something wrong with the code? Am I overlooking something really obvious 
My code:
Private Sub Form_Paint()
Const pi As Double = 3.142
'draw the circle on which the stimuli will be centred
Me.Circle (Me.ScaleWidth / 2, Me.ScaleHeight / 2), 5.74, vbGreen
'find points on the circle at specified radians
'(6 equally spaced locations)
'and centre a small circle at each point
Dim x, y As Integer
x = (Cos(2 * pi) * 5.74) + Me.ScaleWidth / 2
y = (Sin(2 * pi) * 5.74) + Me.ScaleHeight / 2
Form1.Circle (x, y), 0.64, vbGreen
Dim x2, y2 As Integer
x2 = (Cos(pi / 3) * 5.74) + Me.ScaleWidth / 2
y2 = (Sin(pi / 3) * 5.74) + Me.ScaleHeight / 2
Form1.Circle (x2, y2), 0.64, vbRed
Dim x3, y3 As Integer
x3 = (Cos(5 * pi / 3) * 5.74) + Me.ScaleWidth / 2
y3 = (Sin(5 * pi / 3) * 5.74) + Me.ScaleHeight / 2
Form1.Circle (x3, y3), 0.64, vbBlue
Dim x4, y4 As Integer
x4 = (Cos(4 * pi / 3) * 5.74) + Me.ScaleWidth / 2
y4 = (Sin(4 * pi / 3) * 5.74) + Me.ScaleHeight / 2
Form1.Circle (x4, y4), 0.64, vbYellow
Dim x5, y5, x6, y6 As Integer
x5 = (Cos(pi) * 5.74) + Me.ScaleWidth / 2
y5 = (Sin(pi) * 5.74) + Me.ScaleHeight / 2
Form1.Circle (x5, y5), 0.64, vbCyan
x6 = (Cos(2 * pi / 3) * 5.74) + Me.ScaleWidth / 2
y6 = (Sin(2 * pi / 3) * 5.74) + Me.ScaleHeight / 2
Form1.Circle (x6, y6), 0.64, vbMagenta
'Draw a point at the centre of each circle
Me.DrawWidth = 3
Me.PSet (Me.ScaleWidth / 2, Me.ScaleHeight / 2)
Me.PSet (x2, y2)
Me.PSet (x5, y5)
Me.PSet (x6, y6)
Me.PSet (x, y)
Me.PSet (x3, y3)
Me.PSet (x4, y4)
End Sub
The result:

PS: The scale is set to centimetres.
-
Jan 9th, 2013, 10:34 AM
#4
Thread Starter
Junior Member
-
Jan 9th, 2013, 11:12 AM
#5
Re: [RESOLVED] Dividing a circle
If you don't want to bother with the trig-functions, the coordinates for the regular unit-hexagon with center (0, 0) are:
{ (1, 0), (0.5, sqrt(3/4)), (-0.5, sqrt(3/4)), (-1, 0), (-0.5, -sqrt(3/4)), (0.5, -sqrt(3/4)) }
In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)
-
Jan 10th, 2013, 05:24 AM
#6
Thread Starter
Junior Member
Re: [RESOLVED] Dividing a circle
Ah, yes! That would be quite helpful because although I've managed to centre the circles, they're still not equally spaced
However... I'm not sure how to draw a hexagon... I mean, what kind of argument do you use to input these coordinates? I'd be great if there was a Me.Hexagon option, but I sense it's bound to be more to it and I don't seem to be able to figure it out 
Oh! And of course, thank you very much for the suggestion!
-
Jan 10th, 2013, 10:40 AM
#7
Re: [RESOLVED] Dividing a circle
 Originally Posted by Pine_Apple
......they're still not equally spaced 
As I see it, the coordinates you are using are correct, you are already using the same coordinates as Pine_Apple suggested, although you do compute them using Cos and Sin.
Your point x;y uses Cos(2Pi) and Sin(2Pi) which are 1 and 0
your point x1;y1 uses Cos(Pi/3) and Sin(Pi/3) which are 0.5 and Sqrt(3/4) or better 0.86666..
etc...
So, why do you think your points (which form a hexagon, although "you can't draw it") are not equally spaced?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jan 10th, 2013, 12:06 PM
#8
Thread Starter
Junior Member
Re: [RESOLVED] Dividing a circle
 Originally Posted by opus
So, why do you think your points (which form a hexagon, although "you can't draw it") are not equally spaced?
Yeah... it makes no sense for them to not be spaced equally cause the coordinates are correct, I'm sure of that! However, they aren't! In the end I actually measured them manually by placing a protractor on the monitor (oh yes, I went there!) and it turned out the first angle was 62 instead of 60, and then next proportion was 58 So everything was off by approximately 2 degrees. No idea why... so I 'cheated' by centering the small circles at 59, 121, 239 and 301 degrees. This almost corrected for it. It seems fine now...
-
Jan 10th, 2013, 02:04 PM
#9
Re: [RESOLVED] Dividing a circle
As I see it, the only place that the error can arise is due to your approximation of Pi with 3.142.
Pi represented as a double is actually 3,14159265358979.
In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)
-
Jan 11th, 2013, 08:37 AM
#10
Thread Starter
Junior Member
Re: [RESOLVED] Dividing a circle
Yeah, I thought so too! But it didn't make any difference There must be something fundamentally wrong with the scales because I also just noticed that the centimetre measurements are not accurate either... e.g. I set diameters of 1.28 and and 7.02, instead it generates them as 1.6 and 8.7 (approximately). Well... I don't think I can do anything about that but bite the bullet and somehow try to work around it 
Thanks for the help and tips!
Edition: Oups.. I messed up those values a bit, that's not exactly how they turned out, but it doesn't matter cause the fact is that the centimetre measurements are not accurate.
Last edited by Pine_Apple; Jan 11th, 2013 at 08:49 AM.
-
Jan 11th, 2013, 10:55 AM
#11
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|