spinning line!!!!!

Started by
5 comments, last by chaoticseed 22 years, 7 months ago
Can some one plz tell me how i would make a regular line spin clockwise with visual basic? All the code! thx u
Advertisement
Well to spin you have to have a point to spin around. That would be the center of a circle. You are then drawing a line from the point on the circle to the center. The point on a circle is x=cx+r*cos(theta) and y=cy+r*sin(theta) where (cx,cy) is the center, r is the radius and theta is the angle with the x-axis. If you use degrees then theta ranges from 0 to 360 for a full circle. If you use radians then it ranges from 0 to 2pi. Drawing from a point on the circle to the center will make the line spin around the end of the line, i.e. the center. If you wanted it to spin around the center of the line then you would draw a line from the first point through the center to a point directly opposite it. That second point would be 180 degrees off of the first point or theta+180 rather than theta for degrees or theta+pi for radians. If you wanted it to spin about a differant point on the line you would have to use a second radius for the second point, i.e. x=cx+r2*cos(theta+180). You can also make it spin around the point not on the line by using a value other than 180 for the second point. You can also play games with circles with differant centers and multiplying theta by some value.
Keys to success: Ability, ambition and opportunity.
Thx a lot, I understand for the most part, honestly!
But how do i put that down as code, to really make a line spin?
I''ve just been trying to accomplish this for some days now, and im gettin frustrated with it. All the examples i''ve been getting from ppl don''t put it out in code so im stuck figuring out where to plug in variables and such. If someone could just write out a little snippet of how-to-do, id be much abliged!
thx u.


P.S. Do i create a line in visual basic then from their?
x = cx + r * cos(theta) or x = cx + r * cos(360)
y = cy + r * sin(theta)

line1.x1 = cx + r * cos(theta)
line1.x2 = cy + r * sin(theta)

See, im very confused as to how i implement this feature into code. I appreciate the hlp thx again!

You are really in the wrong forum if you need help with code. This is for math and physics. Really a place for theories and general algorithms about math and physics. Not really a forum for code.
Try here There should be some help files that came with Visual Basic and I would suggest getting familar with those. Also you are more likely to get help on general visual basic programming on either the general programming board or a board dedicated to visual basic.
Keys to success: Ability, ambition and opportunity.
A couple of things: theta is not a magic word. Theta is just a name that''s usually used for the variable that contains the angle of rotation. For spinning, you''ll want that angle of rotation to start at some value and then either increase or decrease by a certain amount each frame.

Here''s the basic concept:


''Each frame... (maybe put in a timer event)line.x1 = sin(theta) + center_xline.y1 = cos(theta) + center_yline.x2 = -sin(theta) + center_xline.y2 = -cos(theta) + center_ytheta = theta + 1 

This topic is closed to new replies.

Advertisement