Trigonometry, matrix math, and radians...

Started by
11 comments, last by Yanroy 23 years, 3 months ago
quote:Original post by Yanroy

I''m starting to feel like this thread is a monologue, but I figured out why it is jumping in 30 degree or so hops. The deg-to-rad macro is wrong! That was the only thing I could think of, so I tried to work it out on my own:

360 deg = 2 * PI rad

So I made the degrees into a fraction of a circle:

(Angle / 360) = some part of a circle

If a whole circle is 2 * PI, then part of a circle is:

(Angle / 360) * 2 * PI
or
(Angle / 180) * PI

I put that formula in my program, and voila (how do you do accented characters?), it works! It still rotates in the wrong direction, but that is another problem. And there are still holes in it, but it turns at a normal rate. Any help with my many other problems would be great.

Peon: your formula is correct, and Quantum either made a mistake with the parentheses or I don''t understand what he is driving at.

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming


You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.




Sorry I had them round the wrong way. It was late At least the concept was right
Advertisement
360 degrees = 2 pi radians

Getting rid of the "holes" is (in my oppinion) fairly simple.
Instead of rotating a coordinate on the texture to get the screen coordinate you should rotate the screen coordinate to get the texture coordinate.

However you shouldn''t rotate every point on the screen (unless of course the polygon covers the entire screen). Instead you should:

1. Rotate the corners
2. Split the polygon into horizontal lines
3. For every pixel you rotate the screen coordinate to get u,v

Or you could:

1. Rotate the corners
2. Split the polygon into horizontal lines
3. For each line you interpolate u,v for both ends of the line
(along the edge of the polygon)
4. For each pixel you interpolate u,v (between the ends of the
line)

If you didn''t understand everything I said, you should read about polygon filling and affine texture mapping.
. . . and for really nice rotated images you could could find the 4 closest pixels in the source image, calculate the their distance from the destination pixel, and calculate the colour from that; It''s super slow but it look sweet; I don''t recomend it for real-time drawing, though; It''s probably more work than it''s worth;

This topic is closed to new replies.

Advertisement