God. I am useless at geometry.
I'm trying to work out how to rotate my targets on bloop.
The theory is simple, I take the texture area for my graphic, and when rendering it, rotate all of the vertex points around the centre of the vertices by my angle.
Is the theory sound? If I give the PVR points that represent a 'diamond' rather than a 'square' it should plot them correctly, right?
OK, so based on that, how should I do the rotation? I'm having a real nightmare... a code sample would help ... and it seems so simple.... help?!
=W=
Rotation!!!!
-
- DC Developer
- Posts: 453
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu May 16, 2002 8:29 am
- Location: ice88's house
- Has thanked: 0
- Been thanked: 0
- Contact:
-
- DC Developer
- Posts: 2648
- Joined: Sun Mar 24, 2002 7:48 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
I can do it on SDL dont think that will help thou i can make any sprite rotate with a routine i wrote but its heavly SDL dependent
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *
http://r2k2gate.topcities.com *dev site and my releases*
Im' a Commodorian are you?
http://r2k2gate.topcities.com *dev site and my releases*
Im' a Commodorian are you?
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
You just want code to rotate a vertex, yes? So that, given the offset in X and Y coordinates relative to the center of rotation and the angle of rotation, you can work out the rotated X and Y coordinates.
Basically you can use matrices to do it, and then turn those into a simple(ish) formula for rotation.
Taking the initial X and Y coordinates to be X1 and Y1, the angle to be A and the final X and Y coordinates to be X2 and Y2, we get the following matrix equationConverting this to two standard equations, we get this:
And some code that uses it might look like thisThat implementation's crap, but you should get the idea.
Basically you can use matrices to do it, and then turn those into a simple(ish) formula for rotation.
Taking the initial X and Y coordinates to be X1 and Y1, the angle to be A and the final X and Y coordinates to be X2 and Y2, we get the following matrix equation
Code: Select all
[ cos(A) sin(A) ][X1] = [X2]
[-sin(A) cos(A) ][Y1] = [Y2]
Code: Select all
X2 = X1 * cos(A) + Y1 * sin(A)
Y2 = X1 * -sin(A) + Y1 * cos(A)
Code: Select all
void RotatePoints(float inX, float inY, float ang, float *outX, float *outY)
{
*outX = inX * cos(ang) + inY * sin(ang);
*outY = inY * cos(ang) - inX * sin(ang);
}
void whatever()
{
float rx, ry;
RotatePoints(10.0, 5.0, 1.3, &rx, &ry);
}
-
- DC Developer
- Posts: 453
- Joined: Thu May 16, 2002 8:29 am
- Location: ice88's house
- Has thanked: 0
- Been thanked: 0
- Contact:
OK - that sounds like it ought to work.... I'll have another go!!!!
Thanks!
-W-
Thanks!
-W-
Read my blog: http://unrational.blogspot.com