|
-
Jul 1st, 2000, 05:31 AM
#1
Thread Starter
Lively Member
Hi,
I'm trying to make sort of a pie chart. I have a circle and a line that appear when my form loads. I also have a textbox and a command button. The idea is this: a person enters a number into the textbox, and when they click the command button the figure entered in text1 is given as an angle with the line at Form_Activate, from the centre of the circle:
Private Sub Form_Activate()
Circle (1000, 1000), 1000
'north
Line (1000, 1000)-(1000, 0)
'east
'Line (1000, 1000)-(2000, 1000)
'west
'Line (1000, 1000)-(0, 1000)
'south
'Line (1000, 1000)-(1000, 2000)
End Sub
'and when they click command button:
Private Sub Command1_Click()
Line (1000, 1000)-(1000 + Text1 * 11.11, 0 + Text1 * 11.11)
End Sub
The way I had planned was by getting the X2 and Y2 coordinates of two lines, both of length 1000, for 0 degress and for 90 degress, from the centre of the circle.
These coordinates are:
0 degrees: (1000,0)
90 degrees: (2000,1000)
Then I divided 1000 by 90, which is 11.11 (Let this equal 1 degree). So if someone enters 10 in text1, the X2 coordinates of the line will move 1000 + 10 times 11.11, and the Y2 coordinates will move 10 times 11.11.
But it doesn't work. It works fine for 90 degrees, exactly, but the lines are all different lengths for different angles, apart from that.
So in a nutshell, how can I draw lines at an angle (whose size is specified in text1) with the line at Form_Activate, from the centre of the circle?
Thanks for any help!
-
Jul 1st, 2000, 03:46 PM
#2
transcendental analytic
Easy trig:
Code:
line(x,y)-step(cos(angle)*radius,sin(angle)*radius)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 1st, 2000, 08:05 PM
#3
Thread Starter
Lively Member
Kedeman,
How do you mean, 'easy trig'?
I cut and pasted your code in the following ways:
Private Sub Command1_Click()
Line (1000, 1000)-Step(Cos(Text1.Text)* radius, Sin(Text1.Text) * radius)
End Sub
Private Sub Command1_Click()
Line (x, y)-Step(Cos(Text1.Text)* radius, Sin(Text1.Text) * radius)
End Sub
Private Sub Command1_Click()
Line (1000, 1000)-Step(Cos(angle)* radius, Sin(angle) * radius)
What do Cos and Sin do? (Do I havve to put them as a string or something?
End Sub
-
Jul 2nd, 2000, 04:22 AM
#4
transcendental analytic
Oh, sorry i didn't know you didn't know, Trig for Trigonometry:
Sin stands for Sinus, Cos for Cosinus and is both VB functions
Set the radius to which radius you want your pie to have, In this case text1 (if that's what you wanted to have it)
The angle, is specified in radians so if you need to convert between radians and degrees:
deg=rad*180/3.1415
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 2nd, 2000, 04:30 AM
#5
transcendental analytic
Well here's a quick overview
a and b are angles while A,B and C are the length of the sides:
Code:
|\
|a\
| \
| \
| \
|A \B
| \
| \
|___C___b\
sin(a)=C/B=cos=(b)
cos(a)=A/B=sin(b)
tan(b)=A/C
tan(a)=C/A
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 2nd, 2000, 12:04 PM
#6
Thread Starter
Lively Member
Allez Zou Zou!!!
Thanks Kedeman,
I haven't tried your code but I'll look at it tonight after France kick Italy's ass in Euro 2000 in an hour. (I hope you're not Italian?).
If you're not from these parts then you probably don't know Euro 2000 is a big foot ball event. And France will win. Because they have......Zidane. The King of Style.
-
Jul 2nd, 2000, 12:11 PM
#7
Actually Euro 2000 is popular here in North America. (At least where I'm from).
-
Jul 2nd, 2000, 03:07 PM
#8
transcendental analytic
Well, i'm from Finland, Not Italy, actually I don't watch Foot ball...
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|