Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jollyjeffers

Rotating a 2D array

This topic is 6498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, say I have an array of points (2D) [9][9] in a standard pattern: 000000000 000000000 000000000 000000000 000000000 000000000 000000000 000000000 000000000 how can I rotate them all about 45 degrees? say I have the origin as the point at [0][9] - and I rotate them all around that.... it''d basically end up looking like an isometric diamond... any help is much appreciated.. Jack,

Share this post


Link to post
Share on other sites
Advertisement
Rotating in 2D, that''s like rotating around the z-axes. Lemme see...

Should be sum like this :

Point3D Rotate3D(Point3DT P, angle_z)
{
long rx = 0, ry = 0, rz = 0;
long angle_x = 0;
long angle_y = 0;
ry = cos(angle_x) * P.y - sin(angle_x) * P.z;
rz = sin(angle_x) * P.y + cos(angle_x) * P.z;
rx = cos(angle_y) * P.x + sin(angle_y) * rz;
P.z = -sin(angle_y) * P.x + cos(angle_y] * rz;
P.x = cos(angle_z) * rx - sin(angle_z) * ry;
P.y = sin(angle_z) * rx + cos(angle_z) * ry;
return( P );
}

Now, you must assign a 3D point to every point in your array (shouldn''t be so tough, just set the z to... 1, and the x and y to equal the position in the array), and rotate...

Divide Overflow

"Ergos locus" -- Anonymous

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!