Count current velocity of geom for ABS
			10 posts			 • Page 1 of 1		
	
Count current velocity of geom for ABS
hi
i am new at this forum and i can not guarantee a perfect english
my problem :
im working on an anti blocking system (ABS we call it in germany) that controlls the wheels of a car.
everything works but one thing could be better : I change a scene.my.var with onlaserhit AND now what i want: the fade dist of this laser should have the same value as the speed of the car.so i thought i point with another laser at one geom from my car and let it count its current velocity on hit by this one laser and this current vel is equal to scene.my.var2 (that would be the fade dist of the ABS laser). -> If you drive fast , long dist ,if you dont move no (or in real very minimal) dist .
how is it possible to count the current velocity?
thanks for help!
			i am new at this forum and i can not guarantee a perfect english
my problem :
im working on an anti blocking system (ABS we call it in germany) that controlls the wheels of a car.
everything works but one thing could be better : I change a scene.my.var with onlaserhit AND now what i want: the fade dist of this laser should have the same value as the speed of the car.so i thought i point with another laser at one geom from my car and let it count its current velocity on hit by this one laser and this current vel is equal to scene.my.var2 (that would be the fade dist of the ABS laser). -> If you drive fast , long dist ,if you dont move no (or in real very minimal) dist .
how is it possible to count the current velocity?
thanks for help!
yup yup 
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
		yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
 - Posts: 85
 - Joined: Mon Dec 20, 2010 12:02 pm
 - Location: Germany
 
Re: Count current velocity of geom for ABS
Just to make this clear for me. Do you want the speed or the velocity (velocity = [x, y]; speed = x)
			
		- 
				

Rideg - Posts: 948
 - Joined: Tue Dec 15, 2009 5:17 pm
 - Location: Östersund, Sweden
 
Re: Count current velocity of geom for ABS
velocity would be better (for driving on a slope)
			yup yup 
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
		yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
 - Posts: 85
 - Joined: Mon Dec 20, 2010 12:02 pm
 - Location: Germany
 
Re: Count current velocity of geom for ABS
Make a box and a laser. (laser hits to the box)
This code will get you the velocity of your mouse cursor but you can make a box + laser on the car and in the box's onHitByLaser you type: (e)=>{scene.my.carpos = e.pos}
Then you can replace all app.mousePos with scene.my.carpos
Hope it was what you were looking for
 
-Johan
			
		This code will get you the velocity of your mouse cursor but you can make a box + laser on the car and in the box's onHitByLaser you type: (e)=>{scene.my.carpos = e.pos}
Then you can replace all app.mousePos with scene.my.carpos
- Code: Select all
 (e)=>{
scene.my.vel = (app.mousePos - [color(0), color(1)]) / (sim.time - color(2));
color = [app.mousePos(0), app.mousePos(1), sim.time, 0.6]
}
Hope it was what you were looking for
-Johan
- 
				

Rideg - Posts: 948
 - Joined: Tue Dec 15, 2009 5:17 pm
 - Location: Östersund, Sweden
 
Re: Count current velocity of geom for ABS
thanks , its working!  
 
final script
but why has it something to do with the color?
  
its not really important but if you could explain it in short sentences it were nice
one last thing : would you please explain to me how to express an amount in algodoo ( i just know the way to write it " |x| " )
i only need the keys to write that in algodoo nothing else maybe you know.
thank you so far
			final script
- Code: Select all
 (e)=>{
scene.my.carpos = e.pos;
scene.my.vel = (scene.my.carpos - [color(0), color(1)]) / (sim.time - color(2));
color = [scene.my.carpos(0), scene.my.carpos(1), sim.time, 0.6]
}
but why has it something to do with the color?
its not really important but if you could explain it in short sentences it were nice
one last thing : would you please explain to me how to express an amount in algodoo ( i just know the way to write it " |x| " )
i only need the keys to write that in algodoo nothing else maybe you know.
thank you so far
yup yup 
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
		yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
 - Posts: 85
 - Joined: Mon Dec 20, 2010 12:02 pm
 - Location: Germany
 
Re: Count current velocity of geom for ABS
it has nothing to do with the color. he just used the color array to store data. the geometry does change the color over time but if you hide it it won't matter. instead you could also use another variable/array which you or your object doesn't need or you could make arrays for position and time + a variable for velocity. it's just a matter of taste
			
- 
				

KarateBrot - Posts: 825
 - Joined: Mon Aug 31, 2009 7:32 pm
 - Location: Germany
 
Re: Count current velocity of geom for ABS
Du bist aus Deutschland ? Kannst du mir sagen wie ich in algodoo einen Betrag ( |x| ) ausdrücken kann ?  
 
Das mit dem color dachte ich mir schon weil der sich die ganze Zeit geändert hat.
i already thought the color saved a value for a moment i just wondered why espacially the color has been taken for this.
			Das mit dem color dachte ich mir schon weil der sich die ganze Zeit geändert hat.
i already thought the color saved a value for a moment i just wondered why espacially the color has been taken for this.
yup yup 
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
		yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
 - Posts: 85
 - Joined: Mon Dec 20, 2010 12:02 pm
 - Location: Germany
 
Re: Count current velocity of geom for ABS
ja da machste einfach eine funktion dafür. wenn du etwas zum quadrat nimmst wird es immer positiv. dann nur noch die wurzel ziehen um wieder den ausgangswert zu haben.
öffne die konsole (F11) und deklariere eine neue funktion
dann kannst du die funktion in deiner szene für alles verwenden. du schme9ßt einen wert in die funktion und bekommst den betrag raus. zum beispiel:
das kannst du auch in der konsole testen. das mach ich zumindest oft bevor ich was irgendwo in algodoo einprogrammiere.
- - - - -
i just explained how to make an absolute function
			öffne die konsole (F11) und deklariere eine neue funktion
- Code: Select all
 scene.my.betrag := (x) => { (x^2)^0.5 }
dann kannst du die funktion in deiner szene für alles verwenden. du schme9ßt einen wert in die funktion und bekommst den betrag raus. zum beispiel:
- Code: Select all
 scene.my.betrag(-3)
scene.my.betrag(irgendnevariable)
das kannst du auch in der konsole testen. das mach ich zumindest oft bevor ich was irgendwo in algodoo einprogrammiere.
- - - - -
i just explained how to make an absolute function

- 
				

KarateBrot - Posts: 825
 - Joined: Mon Aug 31, 2009 7:32 pm
 - Location: Germany
 
Re: Count current velocity of geom for ABS
gut funktioniert ,danke-
everything clear
 
thanks!
			everything clear
thanks!
yup yup 
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
		yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
 - Posts: 85
 - Joined: Mon Dec 20, 2010 12:02 pm
 - Location: Germany
 
			10 posts			 • Page 1 of 1		
	Who is online
Users browsing this forum: No registered users and 4 guests





