Post Reply 
The Two Train Problem
03-01-2018, 01:03 PM
Post: #10
RE: The Two Train Problem
One more revision:

Code:
EXPORT TRAINS()

BEGIN

// 2018-02-22 EWS
// 2 trains problem

LOCAL d,t,x;
LOCAL v1,a1,v2,a2;

INPUT({d,v1,a1,v2,a2},
"Two Opposing Trains",
{"Dist:","L Vel:","L Acc:",
"R Vel:","R Acc:"},
{"Distance between trains",
"Left Train: Velocity",
"Left Train: Acceleration",
"Right Train: Velocity",
"Right Train: Acceleration"});

// calculation
IF a1≠0 OR a2≠0 THEN
t:=(−(v1+v2)+√((v1+v2)^2+
2*d*(a1+a2)))/(a1+a2);
x:=v1*t+1/2*a1*t^2;

ELSE

t:=d/(v1+v2);
x:=v1*t;

END;
// results

RETURN {"Time",t,
"Position",x};
END;


Next time I'm not going to go so fast before I post. Thanks.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
The Two Train Problem - Eddie W. Shore - 02-23-2018, 05:09 AM
RE: The Two Train Problem - PedroLeiva - 02-25-2018, 02:04 PM
RE: The Two Train Problem - Dieter - 02-25-2018, 06:19 PM
RE: The Two Train Problem - PedroLeiva - 02-25-2018, 10:55 PM
RE: The Two Train Problem - Dieter - 02-26-2018, 10:59 AM
RE: The Two Train Problem - Eddie W. Shore - 02-28-2018, 10:27 PM
RE: The Two Train Problem - Eddie W. Shore - 03-01-2018, 02:35 AM
RE: The Two Train Problem - Eddie W. Shore - 03-01-2018, 02:54 AM
RE: The Two Train Problem - Dieter - 03-01-2018, 08:53 AM
RE: The Two Train Problem - Eddie W. Shore - 03-01-2018 01:03 PM
RE: The Two Train Problem - chromos - 03-01-2018, 02:00 PM



User(s) browsing this thread: 1 Guest(s)