• Advertisement

Archived

This topic is now archived and is closed to further replies.

spinning line!!!!!

This topic is 5976 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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_x
line.y1 = cos(theta) + center_y

line.x2 = -sin(theta) + center_x
line.y2 = -cos(theta) + center_y

theta = theta + 1

Share this post


Link to post
Share on other sites

  • Advertisement