how to make a circle spin ?

Started by
9 comments, last by ravengangrel 13 years ago
hi
i want to turn a circle around it's own center like a ball or car tire

so i got a 2d vector class for my object(circle) position
and i draw a circle using that


Ellipse(backbufferDC,(int)objectpos.x-25 ,
(int)objectpos.y-25 ,
(int)objectpos.x+25 ,
(int)objectpos.y+25);

how can i spin my circle now ?

i've tried this :

x = x*cosf(r) - y* sinf(r);
y = y*cosf(r) + x * sinf(r);


just made my circle to move around a circular path
Advertisement

hi
i want to turn a circle around it's own center like a ball or car tire

so i got a 2d vector class for my object(circle) position
and i draw a circle using that


Ellipse(backbufferDC,(int)objectpos.x-25 ,
(int)objectpos.y-25 ,
(int)objectpos.x+25 ,
(int)objectpos.y+25);

how can i spin my circle now ?

i've tried this :

x = x*cosf(r) - y* sinf(r);
y = y*cosf(r) + x * sinf(r);


just made my circle to move around a circular path


The function you use to draw circles can't handle rotations on its own and rotating a circle doesn't make much sense (it would look the same regardless of how its rotated).

If you tell us what API you are using we might be able to tell you how to rotate other things.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
im using win32 api
and there is going to be a line in the circle to show the rotation (i can't draw this line from the center of circle )
i know it doesn't make much sense but it's a project for school so ...
Can you just draw the circle and then rotate one endpoint of the line? That is, one end point is the center point of the circle, the other end point is the point (circle_x, circle_y + radius), which you then rotate?
like i said i can't draw the line from the center point of circle
You can't means that you aren't able to, or that doing so will not fulfill your requirements?

What kind of line will you use? Are you looking for one that spans the diameter rather than the radius?
actually our teacher said we shouldn't do that cuz that way we can spin the line instead of circle

the line should be in the random place inside of circle so we can tell whether our circle is spinning around its center or not
It's impossible to rotate a circle - at least in computer graphics terms where a circle is defined by its center-point and a radius. I would do the following: store your circle-with-a-line-in-it as a class, give it two vectors as members, one for its center-point and one to represent its orientation. Then when you draw this construct you draw the circle (without rotation of any kind, that doesn't make sense - use the construct's center-point vector member as the origin of the circle obviously) and then you determine a line from the center of your circle out into the direction the whole thing is pointing (using the second member vector, the orientation) and just draw a segment (a part) of that line.

delme.png
This is what you would get, the small red line is your orientation member vector which would not be drawn, instead the small thick black segment of it is drawn.

Hope this makes sense and helps.

like i said i can't draw the line from the center point of circle


As many have already said, it is impossible to see the visual effect of a rotating plain uniform circle and since you cannot draw a line from center point of circle, why don't you try drawing a few lines that are perpendicular to any radial line inside the circle? That would make the rotation more obvious.
1. Implicit form
( x - x[sub]0[/sub] )[sup]2[/sup] + ( y - y[sub]0[/sub] )[sup]2[/sup] - R[sup]2[/sup] == 0
Each pair {x,y} that fulfills the above equation is a point on the circle centered at (x[sub]0[/sub],y[sub]0[/sub]) and with radius R. AFAIK no rotation can be expressed within.

2. Parametric form
{ x = R cos( 2pi*t+p ), y = R sin( 2pi*t+p ) } w/ t in [0,1]
where a rotation in the given space can be expressed by varying the phase p.

3. Any form is given in a space, and the space can be rotated with the circle within and with respect to the reference space.

4. The (combined) visual representation of circle and line (i.e. a bitmap) can be rotated, what could be understood as a special case of 3. (kind of rotating in "pixel space").

However, as is written several times above, the visual representation will not change besides artifacts due to sampling. Demanding that the indicator line should not be rotated by itself because it would not be a proof that the circle rotates is senseless, because line and circle are 2 distinct objects anyway. That said, what sense does it make to rotate the circle in that way? Is the exercise correctly understood?

This topic is closed to new replies.

Advertisement