Assertion failed when setting rotation

Hey there,

I'm stuck with a problem that I can't seem to figure out. I'm trying to set the rotation for newly made boxes and keep ending up with assertion failed errors while running the program.

Code:
rd = atan(yd/xd);
printf("%6.4f\n", rd);
tempbox[tempboxcounter].localRotation = rd;


What kind of values are valid for the localRotation? in my example, rd is varying between -1.55 and +1.55. But even when I set the rotation to a constant value like 0.9f, 1.2f or 2.0f I get assertion failed's at what seems to be random times. If I comment out the localRotation line, I never get any. Can you give me some insight in how to use this correctly? :S Am I doing something else wrong?

Should make a forum for stupid questions. I feel ashamed of making a new post for this..
This won't be the cause of your assertions, but as a general rule, I would use atan2(y, x) instead of atan - as you noted, atan spits out something between -pi/2 and +pi/2, which is only half of the range of full rotations. atan2 goes from -pi to +pi, and takes the signs of the inputs into account. For boxes it really doesn't matter, but for other shapes it will.

If you do any Excel programming, watch out - atan2 has the arguments reversed (yes, that makes more sense, but it runs counter to the past several decades of computer programming, so...).

No idea off the top of my head why localRotation is causing problems, though, sorry.
Hey, thanks. I found both atan and atan2 on the internet and wasn't sure which one to use.

It seems when I make the boxes bigger in size, I get less assertian failed's? By the way I'm putting more then one shape in a body, if that would make a difference.
Please post the assertion message and the call stack.
I hope this is what you're asking for. It seems to show more information then backtrace or frame #. If it's not what you meant, can you tell me how to show you the right thing in gdb? Sorry, very new to the whole debugging thing.

Seems like the call is:
Code:
b2Assert(3 <= m_vertexCount && m_vertexCount <= b2_maxPolyVertices);

The error is:
Code:
/box2d/Build/Xcode/../../Source/Collision/b2Shape.cpp:481: failed assertion `(s >= 0.0f)'

This is the backtrace:
Code:
#0  0x9638447a in __kill ()
#1  0x9638446d in kill$UNIX2003 ()
#2  0x963fb782 in raise ()
#3  0x9640ad3f in abort ()
#4  0x0004ddfd in __eprintf (string=0x0, expression=0x0, line=0, filename=0x0) at /var/tmp/gcc/gcc-5465~16/src/gcc/libgcc2.c:1838
#5  0x00041434 in b2PolyShape::b2PolyShape (this=0x83d284, def=0x7140, body=0x0, newOrigin=@0x83b76c) at /box2d/Build/Xcode/../../Source/Collision/b2Shape.cpp:433
#6  0x0004204b in b2Shape::Create (def=0x7140, body=0x83b724, center=@0x83b76c) at /box2d/Build/Xcode/../../Source/Collision/b2Shape.cpp:520
#7  0x0004325a in b2Body::b2Body (this=0x7140, bd=0xd6e0, world=0x0) at /box2d/Build/Xcode/../../Source/Dynamics/b2Body.cpp:118
#8  0x00044754 in b2World::CreateBody (this=0x2ce000, def=0xd6e0) at /box2d/Build/Xcode/../../Source/Dynamics/b2World.cpp:79
#9  0x00002094 in startShape (hands={n = 1, hand = {{id = 0, gesture = {gest = "23698741", '\0' <repeats 191 times>}, cx = 0.454687506, cy = 0.716666639, area = 0.0013, xsize = 0.0312249903, ysize = 0.0416333191}, {id = 0, gesture = {gest = '\0' <repeats 199 times>}, cx = 0, cy = 0, area = 0, xsize = 0, ysize = 0} <repeats 79 times>}}, status=1) at /test04/HelloWorld.cpp:159
#10 0x000025a8 in pollRTN () at /test04/HelloWorld.cpp:258
#11 0x000025d4 in timerFunc (value=596) at /test04/HelloWorld.cpp:266
#12 0x3e023965 in __glutTimerCallBack ()
#13 0x909d6b7e in CFRunLoopRunSpecific ()
#14 0x909d6d38 in CFRunLoopRunInMode ()
#15 0x90c908a4 in RunCurrentEventLoopInMode ()
#16 0x90c906bd in ReceiveNextEventCommon ()
#17 0x90c90531 in BlockUntilNextEventMatchingListInMode ()
#18 0x9517dd5b in _DPSNextEvent ()
#19 0x9517d6a0 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#20 0x3e011af9 in -[GLUTApplication _runMainLoopUntilDate:autoreleasePool:] ()
#21 0x3e011ca0 in -[GLUTApplication run] ()
#22 0x3e023313 in glutMainLoop ()
#23 0x000030e5 in main (argc=1, argv=0xbffff708) at /test04/HelloWorld.cpp:344

This is the call stack?
Image
You seem to be running an unstable SVN version. Please use version 1.4.3.
Yeah, that did it. My bad 🙄

Original thread: https://box2d.org/forum/viewtopic.php?t=183