[quote author=Fu-Kwun Hwang link=topic=1845.msg6646#msg6646 date=1277108633]
I did check out your ejs code.
There are several strange code
1. Why the drawingPanel was assigned to be autoscale?
[/quote]
so that maximum view is achieved.
Lmax was original 10, i need to customize it to only 1 metre cos in school, the length of the ramp is about 1.2 m
if i keep Lmax = 10 m, and i vary L, the mainview becomes a very small car and ramp with about of empty space, because L = 10m, so i made L = 1m
and with autoscale, the view is squared and maximum. should i make the view constant?


[quote author=Fu-Kwun Hwang link=topic=1845.msg6646#msg6646 date=1277108633]
2. Why maxX= -carSize/2 ???
[/quote]
it is commented cos i was debugging it.  :D
Fixed relations.FixRel Page(43): //maxX= -carSize/2;

[quote author=Fu-Kwun Hwang link=topic=1845.msg6646#msg6646 date=1277108633]
3. Why Lmax was not defined?
[/quote]
Lmax = 0.

[quote author=Fu-Kwun Hwang link=topic=1845.msg6646#msg6646 date=1277108633]
You should have assigned initlal value for defined variables.
[/quote]
ok, but i blank them because the applet accepts new values after reset button, which is how i make the applet remember/stored previous user inputs without much troublesome variables assignment techniques such as variable_stored to remember last user values.

[quote author=Fu-Kwun Hwang link=topic=1845.msg6646#msg6646 date=1277108633]
I do not know how to change your code because I do not know the specification for your simulation.

The code in the event are strange,too!

If I have something bounced between xmin and xmax (xmax>xmin)

I will have code like this for zero condition:
[code]
if (v>0)return x-xmax; // bounced at x=xmax
else if(v<0)return x-xmin; // bounced at x=xmin
return 1;
[/code]
// the event occurs when return value is less than zero.

And the action will be
[code]
v=-e*v;
[/code]

[/quote]
interesting, i never did zero crossing before! thx for the tip!

i modify the idea from Ejs default examples http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=797.0
but you are right, i could not get the applet to detect the state correctly  sometimes, so i changes the dt =0.1 to 0.05 s thinking it will lesser the detection state error.
i have adopted your zero crossing method
[code]if (v>0) return x+carSize/2-xbumperbottom; // bounced at x=xmax
else if(v<0)return x-carSize/2-xbumpertop; // bounced at x=xmin or x+carSize/2
return 1.0;
//return 1.0;[/code]
action
[code]v=-e*v;[/code]
will try all the more elegant coding!
thx!