 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
ventalator
Joined: 05 Apr 2007 Posts: 2
Digg It |
Posted: Thu Apr 05, 2007 2:34 pm Post subject: |
|
|
I was wondering if anyone has any idea of the algorithm/equation used in GlovePIE's MapRange function?
It's driving me nuts cause i'm trying to use it to replicate the SoundAngle script in C# (which i've got working) but i've realised that my crapy algorithm only works when i'm mapping an angle between -90 and 90 to a range of 13-100... So obviously i'd like my function to be as robust as Carl's :p
Any help would be much appreciated. |
|
| Back to top |
|
 |
TiagoTiago
Joined: 20 Jan 2007 Posts: 710 Location: Brasil
Digg It |
Posted: Thu Apr 05, 2007 6:59 pm Post subject: |
|
|
I believe maprange does just some simple math, somthign like
| Code: | | var.newvalue = maprange(wiimote1.pitch, -90,90,13, 100) |
would be more or less like
| Code: | var.orimin = -90
var.orimax = 90
var.newmin = 13
var.newmax = 100
var.newvalue = (((wiimote1.pitch + (0 - var.orimin)) / (var.orimax-var.orimin)) * (var.newmax-var.newmin)) + var.newmin |
_________________ please put the scripts on the wiki so they dont get lost as new stuff is posted!
phpBB doesnt like me,somtimes it will forget to warn me about new replies to threads I asked it to,if you see a thread I should have responded, could please email me?
Last edited by TiagoTiago on Sat Apr 07, 2007 2:38 pm; edited 2 times in total |
|
| Back to top |
|
 |
ventalator
Joined: 05 Apr 2007 Posts: 2
Digg It |
Posted: Sat Apr 07, 2007 6:22 am Post subject: |
|
|
| Really appreciate that TiagoTiago, that works perfectly. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|