Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active September 30, 2015 15:47
Show Gist options
  • Save kenwebb/1819032 to your computer and use it in GitHub Desktop.
Save kenwebb/1819032 to your computer and use it in GitHub Desktop.
Acceleration
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/wb/ (C) Ken Webb Wed Feb 15 2012 06:05:36 GMT-0500 (EST)-->
<XholonWorkbook>
<Notes><![CDATA[
Khan Academy
------------
Title: Acceleration
Description: Calculating the acceleration of a PorsheCalculating the acceleration of a Porshe
Url: http://www.khanacademy.org/video/acceleration?playlist=Physics
InternalName: acceleration
YoutubeId: FOkQszg1-j8
Keywords: physics, kinematics
My Notes
--------
see code
]]></Notes>
<script implName="lang:python:inline:"><![CDATA[
changeInVelocity = 60.0
direction = "East"
changeInTime = 3.0
acceleration = changeInVelocity / changeInTime
print str(acceleration) + " m/s^2 to the " + str(direction)
# http://ideone.com/4Y0ot
# result: 20.0 m/s^2 to the East
]]></script>
<script implName="lang:javascript:inline:"><![CDATA[
var changeInVelocity = 60.0;
var direction = "East";
var changeInTime = 3.0;
var acceleration = changeInVelocity / changeInTime;
println(acceleration + " m/s^2 to the " + direction);
//javascript:(function(){changeInVelocity = 60.0;var direction = "East";var changeInTime = 3.0;var acceleration = changeInVelocity / changeInTime;alert(acceleration + " m/s^2 to the " + direction);})()
]]></script>
<_-.XholonClass>
<!-- domain objects -->
<PhysicalSystem/>
<Car/>
<!-- quantities -->
<ChangeInVelocity superClass="Velocity"/>
<ChangeInTime superClass="Duration"/>
</_-.XholonClass>
<xholonClassDetails>
<Car>
<port name="changeInVelocity" connector="#xpointer(ChangeInVelocity)"/>
<port name="changeInTime" connector="#xpointer(ChangeInTime)"/>
<port name="acceleration" connector="#xpointer(Acceleration)"/>
</Car>
</xholonClassDetails>
<PhysicalSystem>
<Car roleName="Porsche 911">
<ChangeInVelocity>60.0 mph</ChangeInVelocity>
<Attribute_String roleName="direction">East</Attribute_String>
<ChangeInTime>3.0 s</ChangeInTime>
<Acceleration>0.0 (mph)/s</Acceleration>
</Car>
</PhysicalSystem>
<Carbehavior implName="lang:python:inline:"><![CDATA[
# TODO
]]></Carbehavior>
<Carbehavior implName="lang:javascript:inline:"><![CDATA[
acceleration.setVal(changeInVelocity.val / changeInTime.val);
println(acceleration.val + " m/s^2 to the " + direction.val);
]]></Carbehavior>
<Blockbehavior implName="lang:bsh:inline:"><![CDATA[
// This works if pasted in as a last child of Block.
//height.incVal(0.02);
//System.out.print("Java/Beanshell wants something to do. Height:" + height + "\n");
]]></Blockbehavior>
<Blockbehavior implName="lang:jruby:inline:"><![CDATA[
#require 'java'
# This works if pasted in as a last child of Block.
#$height.incVal(0.02)
#puts "Ruby wants something to do. Height: #{$height}"
]]></Blockbehavior>
<Blockbehavior implName="lang:groovy:inline:"><![CDATA[
// This works if pasted in as a last child of Block.
//height.incVal(0.02);
//System.out.print("Groovy wants something to do. Height:" + height + "\n");
]]></Blockbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/wb/ (C) Ken Webb Wed Nov 13 2013 18:31:00 GMT-0500 (EST)-->
<XholonWorkbook>
<Notes><![CDATA[
Khan Academy
------------
Title: Acceleration
Description: Calculating the acceleration of a Porshe
Url: http://www.khanacademy.org/video/acceleration?playlist=Physics
InternalName: acceleration
YoutubeId: FOkQszg1-j8
Keywords: physics, kinematics
My Notes
--------
Updated November 13, 2013, to make it work with the GWT version of Xholon.
]]></Notes>
<script implName="lang:javascript:inline:"><![CDATA[
var changeInVelocity = 60.0; // mph
var direction = "East";
var changeInTime = 3.0; // s
var acceleration = changeInVelocity / changeInTime; // (mph)/s
console.log(acceleration + " (mph)/s2 to the " + direction);
]]></script>
<_-.XholonClass>
<!-- domain objects -->
<PhysicalSystem/>
<Car/>
<!-- quantities -->
<ChangeInVelocity superClass="Quantity"/>
<ChangeInTime superClass="Quantity"/>
<Acceleration superClass="Quantity"/>
</_-.XholonClass>
<xholonClassDetails>
<Car>
<port name="changeInVelocity" connector="#xpointer(ChangeInVelocity)"/>
<port name="changeInTime" connector="#xpointer(ChangeInTime)"/>
<port name="acceleration" connector="#xpointer(Acceleration)"/>
</Car>
</xholonClassDetails>
<PhysicalSystem>
<Car roleName="Porsche 911">
<ChangeInVelocity>60.0 mph</ChangeInVelocity>
<Attribute_String roleName="direction">East</Attribute_String>
<ChangeInTime>3.0 s</ChangeInTime>
<Acceleration>0.0 (mph)/s</Acceleration>
</Car>
</PhysicalSystem>
<Carbehavior implName="org.primordion.script.Behavior_gwtjs"><![CDATA[
var car;
var beh = {
postConfigure: function() {
// set application parameter
$wnd.xh.param("MaxProcessLoops", "1");
// define car
car = this.cnode.parent();
},
act: function() {
// update acceleration value
car.acceleration.val(car.changeInVelocity.val() / car.changeInTime.val());
// update SVG
var svg = $wnd.Snap("#xhsvg svg");
var textEle = svg.select("text#text11");
textEle.node.textContent = car.acceleration.val();
}
}
]]></Carbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg id="svg1384377763454" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="185.0" height="121.0">
<style>
svg#svg1384377763454 rect {
fill: white;
stroke: #a121f1;
stroke-width: 1px;
}
svg#svg1384377763454 rect.rectalt {
fill: #efffdf;
}
svg#svg1384377763454 rect:active {
stroke-width: 2px;
}
svg#svg1384377763454 text {
font-family: "Courier New",courier,monospace;
font-size: 8px;
fill: black;
pointer-events: none;
}
</style>
<title>Acceleration</title>
<g id="toplevelgroup" transform="translate(0,0) scale(2) rotate(0)">
<title>hjsdkhf sdkhfjsdhf skdh</title>
<g id="g1">
<title>Porsche 911</title>
<rect id="Car" x="10" y="10" width="82" height="50" class="rectalt"/>
<text id="text2" x="15" y="20">Porsche 911</text>
</g>
<g id="g9">
<title>acceleration</title>
<rect id="Car/Acceleration" x="16" y="25" width="70" height="30"/>
<text id="text10" x="21" y="35">Acceleration</text>
<text id="text11" x="21" y="46">0</text>
<text id="text12" x="40" y="46">(mph)/s</text>
</g>
</g>
</svg>
]]></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