Computer graphics question

I have a small set of 2d coordinates that I want to rotate 90 degrees and I can’t remember how to do that. IIRC, it is something like (x, y) cross ((cos(theta), 0),(0, sin(theta))), but I can’t remember if that is correct. The stuff I find online is much too complicated for my purposes.

Thanks for your help,
Rob

For starting coordinates x1,y1, and a rotation of 90° CCW,
Isn’t this just x1->y2, y1->-x2?

If you mean x1->y1, y1->-x1, then no, not generally.

Thanks,
Rob

That’s not what I wrote.

For initial coordinates, X1,y1, a rotation without translation of 90°CCW, results in coordinates of x2,y2, such that y2 = x1, and x2 = -y1, unless I am missing something.

In general, to rotate (x,y) to (x’,y’) you could do something like


x' = x*cos(θ) - y*sin(θ)
y' = x*sin(θ) + y*cos(θ)

Is that what you wanted? That’s around the origin, but you could create rotation around some arbitrary point by translating the coordinates appropriately before/after.

Which for 90°, is what I wrote above…

My bad. I miscalculated. Thanks for your help.

Rob

Wikipedia is your friend (and confirms what recessiveMeme said).

On preview, given the 90 degree stipulation, it also confirms what beowulff said.

My failure to credit your reply was an oversight on my part. Of course, you were correct. I just wanted to provide the more generalized solution in the hope that sweeteviljesus would recognize it as his forgotten transformation.

No problem.
I just hoped I didn’t miss something important…

As an aside, I once wrote code to rotate bitmaps by 90° - there are some interesting tradeoffs between algorithmic complexity, execution speed, and memory usage. Of course, these days you just use an API to do it…