Jump to content

  • Log In with Google      Sign In   
  • Create Account

how to make a circle spin ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 maxxx   Members   -  Reputation: 100

Like
0Likes
Like

Posted 16 April 2011 - 02:41 PM

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

Sponsor:

#2 SimonForsman   Crossbones+   -  Reputation: 6325

Like
0Likes
Like

Posted 16 April 2011 - 02:53 PM

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.
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!

#3 maxxx   Members   -  Reputation: 100

Like
0Likes
Like

Posted 16 April 2011 - 04:27 PM

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 ...

#4 dublindan   Members   -  Reputation: 457

Like
0Likes
Like

Posted 16 April 2011 - 10:03 PM

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?

#5 maxxx   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 April 2011 - 04:33 AM

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

#6 rip-off   Moderators   -  Reputation: 8764

Like
0Likes
Like

Posted 17 April 2011 - 05:22 AM

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?

#7 maxxx   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 April 2011 - 06:37 AM

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

#8 d k h   Members   -  Reputation: 435

Like
1Likes
Like

Posted 17 April 2011 - 07:35 AM

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.

Posted Image
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.

#9 fisyher   Members   -  Reputation: 136

Like
1Likes
Like

Posted 17 April 2011 - 08:40 AM

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.

#10 haegarr   Crossbones+   -  Reputation: 4604

Like
1Likes
Like

Posted 17 April 2011 - 08:51 AM

1. Implicit form
( x - x0 )2 + ( y - y0 )2 - R2 == 0
Each pair {x,y} that fulfills the above equation is a point on the circle centered at (x0,y0) 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?

#11 ravengangrel   Members   -  Reputation: 346

Like
0Likes
Like

Posted 17 April 2011 - 12:41 PM

maxxx, could you give us as much information as possible? In particular, what are you studying (you say it's a project for school. Is it high school or college? what is the subject about and what have you already seen?), and the exact the text of the assignment. with as much context information as we could need. As you have put it it doesn't seems to make much sense, so probably there's some misundestanding around there :)

Edit: Hmmm, if you are using, as it seems, the Windows Ellipse() function, you probably should draw a circle and a line into a DC and then apply the rotation with SetWorldTransform function.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS