 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
TiagoTiago
Joined: 20 Jan 2007 Posts: 710 Location: Brasil
Digg It |
Posted: Thu Jun 28, 2007 4:35 pm Post subject: |
|
|
if I'm not mistaken it is somthing like this:
sqrt( sqr(x1 - x2) + sqr(y1 - y2))
it is that trigonometric rule I think, the suqare of the size of the diagonal line of a triangle is equal to the sum of the square of the horizontal and the vertical lines, or somthing like that _________________ 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? |
|
| Back to top |
|
 |
djatzmo
Joined: 01 Jun 2007 Posts: 19
Digg It |
Posted: Fri Jun 29, 2007 1:14 pm Post subject: |
|
|
^^ thanx for the formula! it makes sense!
but as a programming noob i'm stuck again!
this is my script so far:
var.x1=wiimote.dot1x
var.x2=wiimote.dot2x
var.y1=wiimote.dot1y
var.y2=wiimote.dot2y
if Wiimote.dot1vis and wiimote.dot2vis then
var.ent1 = sqr( sqr(var.x1 - var.x2) + sqr(var.y1 - var.y2))
endif
if var.ent1 < ??? then
ctrl+down = wiimote.RelAccZ
else
ctrl=false
endif
now i've to context my var.ent1 with the range of the dots but i don't know how! and when the range of the wiimote is going more and more far away, it should release the ctrl+down order to zoom im im googleearth.
in the script: ??? what value should i use?
Last edited by djatzmo on Mon Jul 02, 2007 9:32 am; edited 1 time in total |
|
| Back to top |
|
 |
djatzmo
Joined: 01 Jun 2007 Posts: 19
Digg It |
Posted: Mon Jul 02, 2007 8:08 am Post subject: |
|
|
hi TiagoTiago,
this is your signatur:
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, please let me know?
but in this board pm is disabled!
have you another hint for me? ^^ |
|
| Back to top |
|
 |
TiagoTiago
Joined: 20 Jan 2007 Posts: 710 Location: Brasil
Digg It |
Posted: Mon Jul 02, 2007 4:29 pm Post subject: |
|
|
then it would be email, I'm adjusting my sig to avoid further confusion
and about your code, add somthing like
and see how the value behaves and what is the value when you place the wiimote there you want the key to be triggered
ps: to get the actual distance in centimeters or other unity would require some trigonometry, I'm not sure how that wold gg, but you can probably check on Carl's 5dof script to get that part _________________ 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? |
|
| Back to top |
|
 |
djatzmo
Joined: 01 Jun 2007 Posts: 19
Digg It |
Posted: Tue Jul 03, 2007 12:08 pm Post subject: |
|
|
ah, debug is very helpful! thx
here is miy new script:
var.x1=wiimote.dot1x
var.x2=wiimote.dot2x
var.y1=wiimote.dot1y
var.y2=wiimote.dot2y
var.SensorBarSeparation = 7.5 inches
if Wiimote.dot1vis and wiimote.dot2vis then
var.ent1 = sqr( sqr(var.x1 - var.x2) + sqr(var.y1 - var.y2))
endif
if var.ent1 > var.IRDstance and wiimote.minus then
ctrl+down = wiimote.RelAccZ
else
ctrl=false
endif
debug= var.ent1
//from here it is from carl kenners 5dof script i don't know if this ist the right part for my script
if wiimote.dot1vis and wiimote.dot2vis then
if var.dot1x <= var.dot2x then
var.leftdot = 1
var.dotdeltay = var.dot2y - var.dot1y
else
var.leftdot = 2
var.dotdeltay = var.dot1y - var.dot2y
end if
var.dotdeltax = abs(var.dot1x-var.dot2x)
var.DotSep = hypot(var.dotdeltax, var.dotdeltay) * 511.5
var.IRDistance = var.SensorBarSeparation * 1320 / var.DotSep
end if
but the values i get from the debug parameter make no sense. it vary from 1 to 9 with 9 digits behind the comma.
example:
1.134908E11 -> i get this valuie when i'm far away and when i'm close to the sensorbar. that make no sense! only E changes!
i think you can ignore the number before the E. i found out, that E11 (about 30 cm) means you are near the sensor bar an E becomes less when you go far away. for example: E9 means something about 1 meter.
but when you come closer (about 15 cm) the numbers will freeze.
maybe i can use the E value in my script but how?
i can't work with the whole number mentioned above ^^
EDIT:
the problem in this script is, that googleearth will zoom out but not while the backward movement only when the wiimote points to the ground or the ceiling. i thibnk there is something wrong with the order wiimote.RelAccZ!
i've replaced this:
if var.ent1 < 1.134908E11 and wiimote.minus then |
|
| Back to top |
|
 |
TiagoTiago
Joined: 20 Jan 2007 Posts: 710 Location: Brasil
Digg It |
Posted: Tue Jul 03, 2007 10:58 pm Post subject: |
|
|
I've gave up trying to figure out what you had in mind and what was worng on that code so instead I striped everything not required to measure the distance from Carl's script, here is what I got:
| Code: | // Change these values:
var.SensorBarSeparation = 7.5 inches // distance between middles of two sensor bar dots
if wiimote.dot1vis then
var.dot1x = (511.5-wiimote.dot1x)/511.5 - (wiimote.dot1y-383.5)/511.5
var.dot1y = (511.5-wiimote.dot1x)/511.5 + (wiimote.dot1y-383.5)/511.5
end if
if wiimote.dot2vis then
var.dot2x = (511.5-wiimote.dot2x)/511.5 - (wiimote.dot2y-383.5)/511.5
var.dot2y = (511.5-wiimote.dot2x)/511.5 + (wiimote.dot2y-383.5)/511.5
end if
// if both dots are visible check which is which and how far apart
if wiimote.dot1vis and wiimote.dot2vis then
if var.dot1x <= var.dot2x then
var.leftdot = 1
var.dotdeltay = var.dot2y - var.dot1y
else
var.leftdot = 2
var.dotdeltay = var.dot1y - var.dot2y
end if
var.dotdeltax = abs(var.dot1x-var.dot2x)
var.DotSep = hypot(var.dotdeltax, var.dotdeltay) * 511.5
var.IRDistance = var.SensorBarSeparation * 1320 / var.DotSep
end if
debug = var.IRDistance |
if you still want to use your "var.ent1" then just set it to whatever var.IRDistance is ( "var.ent1 = var.IRDistance" ) to press a key whenever the wiimote is closer or further than a certain distance do somthing like
| Code: | if (var.ent1 > 6 inches) then
key.a = TRUE
else
key.a = FALSE
endif |
edit: if you're more confortabel with centimeters instead of inches just change that in the script _________________ 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? |
|
| Back to top |
|
 |
djatzmo
Joined: 01 Jun 2007 Posts: 19
Digg It |
Posted: Wed Jul 04, 2007 11:16 am Post subject: |
|
|
^^ wow thanks! now i can measure the distance.
but now i've to implement the order for googlearth to zoom in (ctrl+down) and zoom out (ctrl+up) by back- and forward movements.
your hint doesen't work.
| Code: | if (var.ent1 > 6 inches) then
ctrl+down = TRUE
else
ctrl+down = FALSE
endif |
because when i move the wiimote backwards it is all the time > 6 and so it zomms out permanent!
my idea it is to work with to new varaibels.
one for the actual distance sonething like
| Code: | | var.aktDistance1 = var.IRDistance |
and with:
| Code: | | var.aktDistance2 = var.IRDistance | which measure the distance 500ms later. now i can compare the two values and put them in relation.
my code for this:
| Code: |
var.aktDistance1 = var.IRDistance
wait 500ms
var.aktDistance2 = var.IRDistance
If var.Distance1 > var.aktDistance2 then
ctrl+down = TRUE
else
ctrl+down = FALSE
endif
If var.Distance1 < var.aktDistance2 then
ctrl+up = TRUE
else
ctrl+up = FALSE
endif |
but it doesn't work!
i thing the problem is the loop thing in glove pie. from the readme:
| Quote: |
For loops aren't as useful in PIE as they are in other languages, because PIE is not a linear language.
A PIE script continuously loops through the entire script, even while IF statements are running in the background.
|
so when the programm continusly loop, it can't refer valuse right. do you know what i mean?
maybe i can work with while and do orders?
i would be very pleased if you can help me again! this thing is very complicated for me!  |
|
| 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
|