Rotating a lineshape in visual c++

Pages: 12
Hey all!
I found something interesting i would like to do, but i cant seem to figure out how to do it.
In vc++ you can draw lines that have x1,x2,y1,y2. All i want to do is to rotate them with a timer or a button. I do not need code, all i need is some directions on how are you supposed to alter the coordinates.

(p.s., i want it to rotate by its center)

Any help greatly appreaciated!
dude, i am 14 years old, i have no idea how to use those functions! (duh)
Can you explain them to me?
it says it quite clearly:
x' = x cos ( theta ) - y sin ( theta )
y' = x sin ( theta ) + y cos ( theta )

where x and y are the old coordinates, x' and y' the new coordinates and theta is the angle
Afaik such trigonometry should be taught to you in school, otherwise just borrow a 9th grade mathbook or something.
Will the computer still give correct output if it is fed incorrect input?
what?
Pasted it on to wrong tab when i was going to answer something similar to Angelhoof, and then internet got disconnected before I could delete it before you could ask what.
Forget it.

Anyways, award892, do some maths to go with graphics.h
Last edited on
bazzy, there are no angles, i want to do it all with coordinates, that is what you missed. Or are you expecting me to somehow get the angles?

@angelhoof: i just finished 8 grade dude, we never even studied sinuses and cosinuses
Last edited on
How can you rotate something without an angle?
So you cant? I think it is possible, i just cant think of the function. Since we have coordinates of x and y from both points, why wouldn't it be possible?
Because by definition you rotate by an angle.
If you don't have any angle, the term 'rotation' doesn't make any sense.

Do this experiment:
Grab two sheets of paper, a larger one and a smaller one.
Put the small one over the bigger one.
Dig a hole in the center of the small one with a pencil.
Draw a line on the small sheet in a way that it goes out of the boundary and draws a mark on the big one
Rotate the small sheet around the hole
Mark the new position of the line.
You got an angle
http://i26.tinypic.com/rqylwh.png
but in visual c++ teh shapes haven't got no angles buddy, so what's the use of them ?
The angle is not a property of the shape, it's just the amount of rotation.
Google a bit for 'rotation' and come back when you know something about it, you clearly have no idea of what a rotation is
i know that a thing has to rotate an angle, but i dont want to just change the fkin angle, i want it to rotate like animated!
Do you know what an animation is?
i know its not the same thing, i just do not know how to describe it in another way... I mean frame by frame, well something like that...
If you want to animate it frame by frame, just change the angle in smaller increments each frame until you get to the desired position.

Zhuge, thanks for that post.
NOW I UNDERSTAND WHAT YOU MEANT BAZZY!
I am such a freaking idiot to not understand such a simple thing....
Its late, so im gonna try it out 2morrow and see how it goes.


Last edited on
x' = x cos ( theta ) - y sin ( theta )
does this mean
xNew = xOld * cos(theta) - yOld * sin (theta) ?
Or did i understand it wrongly? couse if theta = 1, i get some stupid random coordinates on the shape
Pages: 12