SbRotation::getValue() Bug?

SbRotation::getValue() Bug?

Post by Joe Lohm » Sat, 22 Jun 1996 04:00:00



Platform:  SGI Indigo^2 running IRIX 5.3
Version:   Inventor 2.1

I am trying to pull the XYZ rotation values out of a SoTransform and put them
in a set of Motif scale sliders.  However, I am getting strange value from
the SbRotation getValue(SbVec3f &axis, float &radians) method.  All my rotation
values are the same.  However, if I use the getValue(float &q0, float &q1,
float &q2, float &q3) method, I get unique values.

Here is a same program and output:

--------------------------------------------------------------
#include <Inventor/Xt/SoXt.h>
#include <Inventor/nodes/SoTransform.h>

#include <iostream.h>

void main(int, char **argv)
{
   SoXt::init(argv[0]);

   SoTransform *trans = new SoTransform;

   trans->rotation.setValue(SbVec3f(1, 0, 0), M_PI );
//   trans->rotation.setValue(SbVec3f(0, 1, 0), M_PI/2.0 );
//   trans->rotation.setValue(SbVec3f(0, 0, 1), M_PI/4.0 );

   float x, y, z;

   trans->rotation.getValue().getValue(SbVec3f(1,0,0), x);
   trans->rotation.getValue().getValue(SbVec3f(0,1,0), y);
   trans->rotation.getValue().getValue(SbVec3f(0,0,1), z);

   cout << "x: " << x << "  y: " << y << "  z: " << z << endl;

Quote:}

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

Output from above program: x: 3.14159  y: 3.14159  z: 3.14159
If you uncomment:          x: 0.785398  y: 0.785398  z: 0.785398

Any help is appreciated.

Thanks,
Joe

 
 
 

1. Bug in SbRotation?

I think SbRotation might have a bug in it. This caused me no small
amount of grief when debugging, so I wrote a tiny test program to try
and verify it. This program _should_ start a rotation at a certain
angle, and then increase it constantly by a certain amount.

#include <Inventor/nodes/SoRotation.h>
#include <stream.h>

#define AMOUNT  M_PI/7
#define INITIAL 5*M_PI/4

void main() {

  SbRotation *rot = new SbRotation;
  rot->setValue(SbVec3f(0,0,1), INITIAL);

  SbVec3f axis;
  float currentAngle, finalAngle;

  while (1) {

    rot->getValue(axis, currentAngle);  
    cout << "Angle is: " << currentAngle;  
    cout << " Adding: " << AMOUNT;

    finalAngle = currentAngle + AMOUNT;

    rot->setValue(axis, finalAngle);
    rot->getValue(axis, currentAngle);
    cout << " Result is: " << currentAngle << endl;

    fflush(stdout);
  }

Sample output:

Angle is: 3.92699 Adding: 0.448799 Result is: 4.37579
Angle is: 4.37579 Adding: 0.448799 Result is: 4.82459
Angle is: 4.82459 Adding: 0.448799 Result is: 5.27339
Angle is: 5.27339 Adding: 0.448799 Result is: 5.72219
Angle is: 5.72219 Adding: 0.448799 Result is: 6.17099
Angle is: 6.17099 Adding: 0.448799 Result is: 5.94658
Angle is: 5.94658 Adding: 0.448799 Result is: 6.17099
Angle is: 6.17099 Adding: 0.448799 Result is: 5.94658
Angle is: 5.94658 Adding: 0.448799 Result is: 6.17099
... and so on....

I would think that the rotation should continue in the clockwise
direction, not wobble back and forth. What's going on here? Any help
would be greatly appreciated!

--
Christopher Kline
http://www.tc.cornell.edu/~ckline/

"Nothing is certain.
 We lead a charmed life." -RPF

2. deph form disparities

3. Bug in SbRotation/OpenInventor 2.1.1?

4. Can snapshot provide postscript format?

5. Bugs, bugs, bugs, bugs

6. WaveFilter Guy Speaks Out

7. Stratavision 3d 5.0 bugs bugs bugs

8. posting test (inore) (0/1)

9. XYZ Axis Rotation from SbRotation

10. Open Inventor SbRotation/SbVec3f default constructor

11. Inventor SbRotation question

12. BUGS BUGS BUGS Please Reply!

13. Grrr.bug bug bug.....