Recent

Author Topic: Rotate Around a point  (Read 4047 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Rotate Around a point
« on: October 23, 2018, 03:57:11 pm »
Hi All and Thanks in advance for any help!

My math is not great and need help: I am *trying* to write a sprite placement editor for personal use and am stuck with the following:

When a 'sprite' <assume angle is zero> is clicked on <selected>, I draw a selection rectangle around it with four corners and a rotation point at extending at the top as follows:

     o
     |
o-------o
|          |
|    x    |
|          |
o-------o

Where x = Origin.

I want to do two things:
1] Rotate 'o' points by angle z around origin x
2] Rotate 'o' points to follow mouse (as in most graphics editing applications)

Can anyone please help?




JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Re: Rotate Around a point
« Reply #1 on: October 23, 2018, 04:04:13 pm »
BTW

Drawing using BGLVritualScreen!

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Rotate Around a point
« Reply #2 on: October 23, 2018, 08:52:28 pm »
Here is example of "raw" drag and drop.
Everything else is pure math. You need to find angle between original xo vector and modified one (new o point coordinates) and use it as rotation transformation angle. Google "angle between two vectors". I don't know, how rotation transformation is performed in framework, you use. If it's just angle or matrix. But it would be more easy to produce rotation matrix directly from initial vectors, than find angle first and then turn it back to rotation matrix.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

 

TinyPortal © 2005-2018