checking a range of values
Blitz3D Forums/Blitz3D Programming/checking a range of values
| ||
I am trying to determine WHERE the wheel stops in my other forum post. I have determined a range of values based loosely on Euler sets to tell what pitch roll and yaw stands for every number on the wheel. I need to compare the final position of the wheel to these values to output what number is showing on the wheel... How? I tried to get fancy with select case but no go. I tried a convoluted If then statement but it did not work. If numbershow < -17 And numbershow > 17 And numberroll=0 Then wheelnumber = 3 If numbershow < 18 And numbershow > 53 And numberroll=0 Then wheelnumber = 2 If numbershow < 54 And numbershow > 90 And numberroll=0 Then wheelnumber = 1How can I check a range of values? BTW numbershow id the entityroll$(mesh) value and numberroll is the entityyaw#(mesh) value. -RZ |
| ||
I think you might need to reverse your comparesIf numbershow > -17 And numbershow < 17 And numberroll=0 Then wheelnumber = 3 If numbershow > 18 And numbershow < 53 And numberroll=0 Then wheelnumber = 2 If numbershow > 54 And numbershow < 90 And numberroll=0 Then wheelnumber = 1 |
| ||
I think you have your < and > the wrong way round... it shouldn't be possible for numbershow to be less than -17 AND more than 17 simultaneously !!! How about if numberroll = 0 then Select true case ( numbershow > -17 And numbershow < 17) wheelnumber = 3 case ( numbershow > 18 And numbershow < 53) wheelnumber = 2 ... etc End Select EndIf ... and have you thought about what happens when numbershow = 18 ?? |
| ||
Dang! I was trying to use this formula to reconvert the Eulers into one simple angle form of 0 to 360 (or thereabouts) I wasn't entirely successful YET, but I think I am on the right track:numbershow=EntityPitch(mesh) numberroll=EntityRoll(mesh) numberyaw=EntityYaw(mesh) wheelnumber = numbershow + numberroll + numberyaw / 90 + 90Let me try to implement what you have... I did not know you could use parenthesis to exhibit a range value for case!!! @Shambler... My dyslexia strikes again!!! : ) |
| ||
I made a similar mistake a couple of days ago ;) |