ofNode get pitch and roll


#1

I’m trying to calculate the pitch and roll values for an ofNode that is rotating around the origin, what I have is:

ofNode parent;
parent.setPosition(ofVec3f(0,0,0));

ofNode n;
n.setPosition(p);
n.lookAt(parent);

p is the position of the node that is moving around the origin. If I call n.getPitch() or n.getRoll() it always returns 0, is there anyway I can get these values?


#2

I’m testing this and it seems to work fine. Would be helpful if you posted an example demoing the problem.


#3
   p = ofVec3f(ofRandom(-100, 100), ofRandom(-100, 100), ofRandom(-100, 100));
ofNode parent;
parent.setPosition(ofVec3f(0,0,0));


ofNode n;
n.setPosition(p);
n.lookAt(parent);

float tiltDeg = n.getRoll();
float panDeg = n.getPitch();

cout << tiltDeg << " " << panDeg << endl;

When I run this code I always get 0 for the roll, no matter what the position of p. Basically what i’m trying to do is move a moving head light that takes a tilt and pan value to make it point it toward a specific x,y,z position.


#4

what version of openframeworks are you suing?

i’m doing:

		ofNode parent;
		parent.setPosition(ofVec3f(0,0,0));

		ofNode n;

		for(int i=0;i<100;i++){
			ofVec3f p(ofRandom(-100, 100), ofRandom(-100, 100), ofRandom(-100, 100));
			n.setPosition(p);
			n.lookAt(parent);
			cout << n.getPitchDeg() << ", " << n.getRollDeg() << ", " << n.getHeadingDeg() << endl;
		}

and getting:

146.833, 180, -71.9608
158.992, 180, 89.8455
153.032, 180, 40.0037
20.6433, 0, 3.42912
-26.4591, -4.79882e-07, -27.1812
-70.0298, 0, 64.4238
29.6938, 0, -11.8708
-120.713, 180, -58.8156
-166.556, -180, -46.786
12.1559, 0, -20.6605
-25.5407, 0, -35.6104
23.208, 0, 40.5904
4.83217, 2.70271e-08, 9.18622
14.9469, 0, 68.227
-129.64, 180, 8.08535
-40.2418, 0, -69.9533
159.379, 180, 7.64937
56.5, -1.74428e-05, 78.7092
31.883, 1.09892e-06, -39.0207
-137.139, 180, 7.51704
115.884, 180, -53.2597
-77.7778, -2.70678e-06, 50.8878
144.852, 180, -81.8847
-179.586, 180, -9.72019
-24.1334, 0, 4.92423
-140.743, 180, -81.7518
12.1111, -6.6736e-07, 50.2331
132.158, 180, 64.8537
146.818, 180, -49.8788
140.209, 180, -60.8057
22.6956, 0, -53.9366
150.871, 180, 52.3331
34.1081, 0, 53.3227
36.5402, -1.12666e-06, -40.7299
-150.286, 180, 54.4498
-20.2542, 0, -54.3404
13.3894, 2.24726e-07, 18.2329
-41.7394, 0, 23.0694
-71.6751, 0, -4.54246
65.5793, 0, -35.601
-56.9306, -1.043e-06, 35.0575
57.1462, 0, -3.86297
-41.0716, 0, 45.545
-4.33979, 0, 87.4443
-23.72, 0, -47.5537
14.0766, -6.13766e-07, 45.9313
-160.921, 180, -32.0184
47.7525, 0, 71.919
159.585, -180, 42.0367
28.0661, 0, 56.7975
-133.695, 180, 34.6792
-33.2013, 0, 50.9517
176.231, 180, 27.786
37.6558, -1.03125e-06, -34.116
-29.7429, -1.06827e-06, 36.9452
163.105, -180, -33.8337
-16.4128, 0, 8.13392
-148.354, 180, 13.2883
-179.518, 180, -30.9907
45.1443, 5.33742e-08, 1.28212
53.8813, 0, 8.11628
-120.16, -180, -60.0054
-162.291, 180, 49.472
15.6397, 0, 45.6046
-163.59, 180, 23.5652
0.562083, 0, -22.8431
-173.644, -180, 53.3301
-10.4463, -6.82697e-07, -51.2962
161.439, -180, 49.0479
14.7759, 1.54346e-05, 86.829
-136.185, 180, -25.2131
42.2786, 0, -66.7956
-14.8058, 5.26001e-07, 35.7504
4.29073, -5.26908e-07, -66.1034
12.7755, 0, -52.1493
-166.341, 180, 60.4285
-10.2436, 0, -54.3417
29.9017, -7.95909e-06, 83.842
-8.20291, 5.42757e-08, 10.5349
44.9611, 7.90366e-05, 88.762
-137.472, 180, 84.1467
-26.4304, -1.06328e-06, -36.586
-179.626, 180, 49.3631
40.6729, 0, -13.7181
-17.8557, 0, 39.1786
118.07, 180, -76.0813
175.31, 180, 70.4941
37.9643, 0, -58.7076
-55.323, 0, 17.7569
-152.167, -180, 33.446
138.866, 180, 40.4662
171.42, -180, -18.9072
155.053, -180, 87.6347
173.611, 180, -80.5551
-5.133, 1.33339e-07, 36.8339
-57.9376, -2.23981e-06, 40.3272
12.2358, 0, -29.2694
43.5576, 1.04197e-06, -34.9769
-39.4071, 0, -46.9003
-107.17, 180, 8.82532

of course being random the values will change but i’m not getting 0 at all


#5

i’m using 9.8 I didn’t think to use the getHeading() function, these are the results i’m getting, which are similar to yours but the roll is still always 0 (or very close to zero) also i’m only getting values from -90 to 90, but I guess i’ve got to work out which way is forward for the ofNode?

-54.0422, 0, 162.131
-58.0211, -1.70755e-06, 94.7009
-26.4984, -8.53774e-07, -87.5112
52.7709, 0, -94.8723
60.0625, 0, 97.0085
-27.422, 8.53774e-07, -115.764
-52.4297, 8.53774e-07, 145.05
53.9588, -1.70755e-06, 71.2354
-65.6544, 0, 151.262
47.0799, 0, -61.8678
-7.3524, 2.13443e-07, 116.016
45.9919, 0, 17.6285
14.0057, 0, -148.864
-49.6408, 4.26887e-07, 17.1339
-53.6121, 0, 122.566
-33.2909, 0, -52.0672
-19.4961, 0, -123.77
22.576, 0, 43.6529
-6.29694, 2.13443e-07, -115.803
-45.9615, 0, 87.3529
-55.0585, 1.70755e-06, 39.1411
53.053, 4.26887e-07, -16.1884
54.4566, 0, 90.9309
-40.9892, -1.70755e-06, -125.394
42.7144, 0, -119.766
41.2783, 0, -71.3391
31.1709, 0, 143.419


#6

that sounds like a bug in 0.9.8 although it’s strange that we didn’t catch it before. i would suggest to use 0.10 since 0.9.8 is not maintained anymore


#7

ok thank you for your help arturo, unfortunately I cannot use 0.10 due to other dependencies with the project but i’ll see if I can copy over the 0.10 ofNode code to my 0.9.8 system.