rotating a cube around origin

This is a discussion on rotating a cube around origin within the Game Programming forums, part of the General Programming Boards category; I'm working on a yahtzee program, and I want to make a neat animation of rolling dice. I've gotten as ...

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    rotating a cube around origin

    I'm working on a yahtzee program, and I want to make a neat animation of rolling dice. I've gotten as far as rendering the wireframe cube, and I've made some rotation functions for each axis that look something like this:

    Code:
    th = atan(y / x);
    if ((x < 0 && y < 0) || (x < 0 && y > 0)) // -1/1 = 1/-1, correct for atan()
      th += pi / 2;
    th += pi / 20;
    x = size * cos(th);
    y = size * sin(th);
    here's the part that stumps me, these functions work fine by themselves, but when I run them more than one at once I get weird (noncube) results. Does anybody have any ideas as to why this might be happening?
    Illusion and reality become impartiality and confidence.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    no not without more code,

    this site explains using matrices to do rotation around an arbitrary axis, which is probably easier.

    http://www.geocities.com/SiliconVall.../matrices.html
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2d Cubik program in C
    By joot43 in forum C Programming
    Replies: 4
    Last Post: 05-25-2009, 08:17 AM
  2. rotating composite objects with OpenGL
    By elad in forum Game Programming
    Replies: 11
    Last Post: 10-19-2008, 08:04 AM
  3. Cube rotation math problem
    By n3v in forum Game Programming
    Replies: 6
    Last Post: 08-03-2007, 06:41 AM
  4. Fixing bug in Quake 2 Engine!
    By hajas in forum Game Programming
    Replies: 4
    Last Post: 06-22-2007, 11:12 AM
  5. Rubix Cube Contest
    By The Brain in forum Contests Board
    Replies: 24
    Last Post: 01-15-2005, 05:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21