Created
February 14, 2012 00:30
-
-
Save kenwebb/1821877 to your computer and use it in GitHub Desktop.
Calculating Average Velocity or Speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Xholon Workbook http://www.primordion.com/Xholon/wb/ (C) Ken Webb Mon Feb 13 2012 19:30:48 GMT-0500 (EST)--> | |
<XholonWorkbook> | |
<Notes><![CDATA[ | |
Khan Academy | |
------------ | |
Title: Calculating Average Velocity or Speed | |
Description: Example of calculating speed and velocity | |
Url: http://www.khanacademy.org/video/calculating-average-velocity-or-speed?playlist=Physics | |
InternalName: calculating-average-velocity-or-speed | |
YoutubeId: oRKxmXwLvUU | |
Keywords: Calculating, Average, Velocity, or, Speed | |
My Notes | |
-------- | |
displacement = 5 km north | |
m meters | |
s with a right-directed arrow on top (it's a vector) | |
time = 1 hour | |
s seconds | |
t (a scalar) | |
velocity | |
m/s | |
v with a right-directed arrow on top | |
v = s / t | |
speed, rate (a scalar) | |
dimensional analysis | |
]]></Notes> | |
<script implName="lang:python:inline:"><![CDATA[ | |
s = 5.0 * 1000.0 # m | |
t = 1.0 * 60.0 * 60.0 # s | |
v = s / t # m/s | |
print str(s) + "m / " + str(t) + "s = " + str(v) + "m/s" | |
# http://ideone.com/43jdb | |
# result: 5000.0m / 3600.0s = 1.38888888889m/s | |
]]></script> | |
<script implName="lang:javascript:inline:"><![CDATA[ | |
var s = 5.0 * 1000.0; // m | |
var t = 1.0 * 60.0 * 60.0; // s | |
var v = s / t; // m/s | |
print(s + "m / " + t + "s = " + v + "m/s"); | |
// paste this into your browser's address bar (exclude the // comment characters): | |
//javascript:(function(s,t){s=s*1000.0;t=t*60.0*60.0;var v=s/t;alert(s+"m/"+t+"s="+v+"m/s");})(5.0,1.0) | |
]]></script> | |
<_-.XholonClass> | |
<!-- domain objects --> | |
<PhysicalSystem/> | |
<Car/> | |
<!-- quantities --> | |
<Displacement superClass="Length"/> | |
<ChangeInTime superClass="Duration"/> | |
<AverageVelocity superClass="Velocity"/> | |
</_-.XholonClass> | |
<xholonClassDetails> | |
<Car> | |
<port name="displacement" connector="#xpointer(Displacement)"/> | |
<port name="changeInTime" connector="#xpointer(ChangeInTime)"/> | |
<port name="averageVelocity" connector="#xpointer(AverageVelocity)"/> | |
</Car> | |
</xholonClassDetails> | |
<PhysicalSystem> | |
<Car> | |
<Displacement>5.0 km</Displacement> | |
<Attribute_String roleName="direction">north</Attribute_String> | |
<ChangeInTime>1.0 h</ChangeInTime> <!-- 1 hour --> | |
<AverageVelocity>0.0 m/s</AverageVelocity> <!-- this will be calculated --> | |
</Car> | |
</PhysicalSystem> | |
<Carbehavior implName="lang:python:inline:"><![CDATA[ | |
# Steps: | |
# (1) Select the displacement, direction, changeInTime, and averageVelocity nodes | |
# in that order. | |
# (2) Run this script by pasting it into the Car node in the Xholon GUI, | |
# or through a Xholon Console on the Car node. | |
snodes = selectedNodesKey | |
print snodes | |
s = snodes[0] # m | |
n = snodes[1] # "north" | |
t = snodes[2] # s | |
v = snodes[3] # m/s | |
v.setVal((s.val*1000.0) / (t.val*3600)) | |
print "v = " + str(v.val) + " " + v.unit + " " + n.val_String | |
]]></Carbehavior> | |
<Carbehavior implName="lang:javascript:inline:"><![CDATA[ | |
// TODO | |
//height.incVal(0.02); | |
//print("JavaScript wants something to do. Height:" + height + "\n"); | |
]]></Carbehavior> | |
<Carbehavior implName="lang:bsh:inline:"><![CDATA[ | |
// TODO | |
//height.incVal(0.02); | |
//System.out.print("Java/Beanshell wants something to do. Height:" + height + "\n"); | |
]]></Carbehavior> | |
<Carbehavior implName="lang:jruby:inline:"><![CDATA[ | |
# TODO | |
#require 'java' | |
#$height.incVal(0.02) | |
#puts "Ruby wants something to do. Height: #{$height}" | |
]]></Carbehavior> | |
<Carbehavior implName="lang:groovy:inline:"><![CDATA[ | |
// TODO | |
//height.incVal(0.02); | |
//System.out.print("Groovy wants something to do. Height:" + height + "\n"); | |
]]></Carbehavior> | |
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml, | |
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient> | |
</XholonWorkbook> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment