You are invited to Log in or Register a free Frihost Account!

# Function "Rotate90", how do do it guys?

GDG
Hey everyone,

I am taking a grade 11 computer science course in high school and I need a bit of help seeing as my exam is tomorrow lol. My teacher gave us some questions from exam, pretty nice and cool guy if you aks me!

Well one question was to define the functions of a class he already made. K here is the class:
 Code: class point { private:           double x, y; public:          point();          double getx();          double gety();          void set (double Xval, double Yval);          void move(double moveX, moveY);          void rotate90(); };

Now my question is how would I define the function : VOID ROTATE90();. It is supposed to move a point or the co-ordinates to a new location in a 90 degree angle. If you do nto understand ask em to explain better!!!!
Shin
I'd be surprise that you can turn a POINT, and what's the point?
GDG
 Shin wrote: I'd be surprise that you can turn a POINT, and what's the point?

Excuse me are you a coder at all lol. If you noticed I made my own class which means it is my own type. Point is another term for the co-ordinates x and y. So I am asking how would I move them to exactly where they would be if in a real graph if I moved them to a point 90 degrees form their original point.
Nyizsa
I think you need a reference point to use as the center of the rotation, and a direction (+90 or -90). Assuming that this is P(0,0), and you rotate the positive way, your function will be as simple as:
 Code: x=-y; y=x;

I hope it helped!