Welcome! Log In Create A New Profile

Advanced

Rotation Coordinates

Posted by LordAshes 
Rotation Coordinates
February 15, 2010 12:40PM
The GRRLIB draw image functions have a rotation parameter which allows you to rotate the image.

However, the image is rotated around the 0,0 point of the image whereas I would like to rotate it around the center of the image.

As far as I can tell, all I should need to do is modify the location (x,y) of the image by some amount based on the angle to bring the image back to the correct position making it seem like it rotated around the image center as opposed to the 0,0 point.

However I seem to be having difficulty getting the correction values.

I will try to google coordinate translation when rotating on google tomorrow but if anyone happens to know the correct compensation values (I am guessing some application of sin and cos) please post them here for myslef and others.

Thanks
Re: Rotation Coordinates
February 15, 2010 03:04PM
If you need to change the centre of rotation you should use GRRLIB_SetHandle. For more information check this page: [grrlib.santo.fr]
Re: Rotation Coordinates
February 16, 2010 03:33AM
Crayon,

Your the best...I would never have guessed that that is what it is what that fucnction is for...without reading the whole GRRLIB documentation for which I don't have time right now.

Thanks I will look up the details for that function.
Re: Rotation Coordinates
February 16, 2010 06:20AM
Remember you could always download the PDF version of the GRRLIB documentation at [code.google.com]

It's useful if you need to make a search on certain key words.
Re: Rotation Coordinates
February 17, 2010 02:25AM
Thanks I have the HTML docs that came with the GRRLIB package but I find it not that well described. I will see if the PDF is any different.

First of all it seems to structure the document around the GRRLIB data structures and GRRLIB files (not GRRLIB functions). In my humble opinion, and maybe I am wrong, I would prefer to have it structured by functions so that I can determine which functions to use and then I can look into what parameters (i.e. data structures) are needed. Otherwise, if I am hunting for a function that performs some action but I don't know what it is called in GRRLIB, I need to guess which GRRLIB file it is in and then I can see the GRRLIB functions that that file contains. Yes, there is a brief indication of what kind of functions the GRRLIB file contains but these descriptions are equally vague.

Next I find the descriptions very vague. For example, I read the data structure for Texture Images which does include x and y handle data. First of all, without you telling me, I would never have guessed that *that* is what handles are used for. On top of that I saw some code which seems to suggest that these pieces of data in the texture image data structure are just user variables which are actually not used when drawing the texture but they can be read to be passed to functions such as SetHandle. This would be nice to know but the HTML docs don't seem to indicate this.

Lastly the description of the functions themselves are, in my opinion, vague. For example, the SetHandles does not really discuss what this affects. Obviously it affects rotation but as I am guessing it will also affect position. So if I center my handles and then draw the image then my image is actually going to have its center at the X and Y position istead of the (usual) top-left corner. This is fine but it would be nice if the description indicated that.

Maybe I am just not reading the right section. As I said, I skimmed the documentation so far because I have not had time to read it fully. As a result, sometimes I just need a little push in the right direction. As soon as you mentioned the SetHandle function then I read up on it and it looks like it is exactly what I need. However, just skimming through the function names I would never have associated SetHandles with this operation.

I know...I know...I should shut up and just read the manual...and as soon as I get some time, that is what I will do.

In any case, thanks for your "push in the right direction" help...much appreciated.



Edited 2 time(s). Last edit at 02/17/2010 02:31AM by LordAshes.
Re: Rotation Coordinates
February 17, 2010 02:35AM
I've never used GRRLIB but what you're trying to do looks pretty simple. The source of GRRLIB is included and is better than any documentation.

GRRLIB_texImg mytexture;

// load etc
......

mytexture.handlex = mytexture.w / 2;
mytexture.handley = mytexture.h / 2;

GRRLIB_DrawImg (xpos, ypos, &mytexture, degrees, 1.0f,1.0f,0x00000000);



Edited 1 time(s). Last edit at 02/17/2010 02:37AM by scanff.
Re: Rotation Coordinates
February 17, 2010 02:49AM
Quote
LordAshes
First of all it seems to structure the document around the GRRLIB data structures and GRRLIB files (not GRRLIB functions).
The complete list of functions is available from this page: [grrlib.santo.fr]

All the documentation is generated from a tool called Doxygen. So the HTML output is not that much flexible. I'm sure this is not the first you look at doc with that aspect. If it is, then it's a good opportunity to learn how to look for something inside the doc, because a lot of projects are using it.

If you can't find in the doc what you are looking for, you could try to search the GRRLIB forum.

If you think you could make the documentation a bit better, don't hesitate to contribute to the project :)
Re: Rotation Coordinates
February 17, 2010 01:30PM
Thanks. I just found out that SetHandle is even easier to use for Rotations because it DOES NOT affect position.

I wrote a bunch of code that would compensate for the handles to get my image in the right position but when I ran it on the Wii I discovered that setting handles does not apply to position so it is just as easy as Scanff wrote.

Thanks everyone.
Sorry, only registered users may post in this forum.

Click here to login