Thread: rotating a cube around origin

  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,263
    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, 07:17 AM
  2. rotating composite objects with OpenGL
    By elad in forum Game Programming
    Replies: 11
    Last Post: 10-19-2008, 07:04 AM
  3. Cube rotation math problem
    By n3v in forum Game Programming
    Replies: 6
    Last Post: 08-03-2007, 05:41 AM
  4. Fixing bug in Quake 2 Engine!
    By hajas in forum Game Programming
    Replies: 4
    Last Post: 06-22-2007, 10:12 AM
  5. Rubix Cube Contest
    By The Brain in forum Contests Board
    Replies: 24
    Last Post: 01-15-2005, 05:33 PM