<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersiveversion='3.0xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.0.xsd '>
<head>
<meta name='titlecontent='ProjectileInterpolatorArena.x3d'/>
<meta name='descriptioncontent='A projectile motion application which displays range and max height values accoding to Vi and theta inputs. Calculations for drag force with air density are also taken into account.'/>
<meta name='creatorcontent='Ozan APAYDIN'/>
<meta name='createdcontent='10 December 2001'/>
<meta name='modifiedcontent='20 October 2002'/>
<meta name='identifiercontent=' http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorArena.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent='../license.html'/>
</head>
<!-- -->
<Scene>
<ExternProtoDeclare name='ProjectileSliderBar'
  url=' "ProjectileSliderBarPrototype.wrl#ProjectileSliderBar" "http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileSliderBarPrototype.wrl#ProjectileSliderBar" "ProjectileSliderBarPrototype.x3d#ProjectileSliderBar" "http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileSliderBarPrototype.x3d#ProjectileSliderBar" '>
<field name='nametype='MFStringaccessType='initializeOnly'/>
<field name='lengthtype='SFFloataccessType='initializeOnly'/>
<field name='widthtype='SFFloataccessType='initializeOnly'/>
<field name='maxValuetype='SFFloataccessType='initializeOnly'/>
<field name='minValuetype='SFFloataccessType='initializeOnly'/>
<field name='barColortype='SFColoraccessType='initializeOnly'/>
<field name='pointerColortype='SFColoraccessType='initializeOnly'/>
<field name='nameColortype='SFColoraccessType='initializeOnly'/>
<field name='currentValueColortype='SFColoraccessType='initializeOnly'/>
<field name='currentValueInttype='SFInt32accessType='outputOnly'/>
<field name='currentValueFloattype='SFFloataccessType='outputOnly'/>
<field name='precisiontype='SFInt32accessType='initializeOnly'/>
<field name='translationtype='SFVec3faccessType='initializeOnly'/>
</ExternProtoDeclare>
<ExternProtoDeclare name='ProjectileInterpolator'
  url=' "ProjectileInterpolatorPrototype.wrl#ProjectileInterpolator" "http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorPrototype.wrl#ProjectileInterpolator" "ProjectileInterpolatorPrototype.x3d#ProjectileInterpolator" "http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorPrototype.x3d#ProjectileInterpolator" '>
<field name='Vitype='SFFloataccessType='initializeOnly'/>
<field name='thetatype='SFFloataccessType='initializeOnly'/>
<field name='B_mtype='SFFloataccessType='initializeOnly'/>
<field name='dttype='SFFloataccessType='initializeOnly'/>
<field name='fractiontype='SFFloataccessType='initializeOnly'/>
<field name='set_fractiontype='SFFloataccessType='inputOnly'/>
<field name='set_thetatype='SFFloataccessType='inputOnly'/>
<field name='set_Vitype='SFFloataccessType='inputOnly'/>
<field name='value_changedtype='SFVec3faccessType='outputOnly'/>
</ExternProtoDeclare>
<Viewpoint DEF='FirstViewdescription='First viewposition='60 15 150fieldOfView='0.7854'/>
<Background groundAngle='1.309 1.571groundColor='0 0 0skyAngle='1.309 1.571'
  backUrl=' "urn:web3d:media:textures/panoramas/space_1_back.jpg" "space_1_back.jpg" "http://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_back.jpg" "http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_back.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_back.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_back.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/space_1_back.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_back.jpg" '
  bottomUrl=' "urn:web3d:media:textures/panoramas/space_1_bottom.jpg" "space_1_bottom.jpg" "http://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_bottom.jpg" "http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_bottom.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_bottom.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_bottom.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/space_1_bottom.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_bottom.jpg" '
  frontUrl=' "urn:web3d:media:textures/panoramas/space_1_front.jpg" "space_1_front.jpg" "http://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_front.jpg" "http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_front.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_front.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_front.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/space_1_front.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_front.jpg" '
  leftUrl=' "urn:web3d:media:textures/panoramas/space_1_left.jpg" "space_1_left.jpg" "http://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_left.jpg" "http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_left.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_left.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_left.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/space_1_left.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_left.jpg" '
  rightUrl=' "urn:web3d:media:textures/panoramas/space_1_right.jpg" "space_1_right.jpg" "http://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_right.jpg" "http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_right.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_right.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_right.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/space_1_right.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_right.jpg" '
  topUrl=' "urn:web3d:media:textures/panoramas/space_1_top.jpg" "space_1_top.jpg" "http://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_top.jpg" "http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/space_1_top.jpg" "http://www.web3dmedia.com/UniversalMedia/textures/panoramas/space_1_top.jpg" "http://www.officetowers.com/UniversalMedia/textures/panoramas/space_1_top.jpg" "http://geometrek.com/UniversalMedia/textures/panoramas/space_1_top.jpg" "http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/space_1_top.jpg" '/>
<DirectionalLight direction='0 -1 0intensity='0.5'/>
<!-- SliderVelocity ROUTE:  [from currentValueFloat to ProjectileInterpolator.set_Vi ] -->
<ProtoInstance name='ProjectileSliderBarDEF='SliderVelocity'>
<fieldValue name='namevalue='Vi'/>
<fieldValue name='lengthvalue='1.5'/>
<fieldValue name='widthvalue='1'/>
<fieldValue name='maxValuevalue='30'/>
<fieldValue name='minValuevalue='0'/>
<fieldValue name='barColorvalue='0 0 1'/>
<fieldValue name='pointerColorvalue='1 1 0'/>
<fieldValue name='nameColorvalue='1 0 1'/>
<fieldValue name='precisionvalue='1'/>
<fieldValue name='translationvalue='-0.04 0.06 0.0'/>
</ProtoInstance>
<!-- SliderAngle ROUTE:  [from currentValueFloat to ProjectileInterpolator.set_theta ] -->
<ProtoInstance name='ProjectileSliderBarDEF='SliderAngle'>
<fieldValue name='namevalue='Theta'/>
<fieldValue name='lengthvalue='1.5'/>
<fieldValue name='widthvalue='1'/>
<fieldValue name='maxValuevalue='90'/>
<fieldValue name='minValuevalue='0'/>
<fieldValue name='barColorvalue='1 0 0'/>
<fieldValue name='pointerColorvalue='1 1 0'/>
<fieldValue name='nameColorvalue='0 1 1'/>
<fieldValue name='precisionvalue='1'/>
<fieldValue name='translationvalue='-0.04 0.05 0.0'/>
</ProtoInstance>
<!-- TimeCycle ROUTE:  [from currentValueFloat to TimeConverter.setTime ] -->
<ProtoInstance name='ProjectileSliderBarDEF='TimeCycle'>
<fieldValue name='namevalue='CycleInterval'/>
<fieldValue name='lengthvalue='1.5'/>
<fieldValue name='widthvalue='1'/>
<fieldValue name='maxValuevalue='5'/>
<fieldValue name='minValuevalue='1'/>
<fieldValue name='barColorvalue='0 1 0'/>
<fieldValue name='pointerColorvalue='1 1 0'/>
<fieldValue name='nameColorvalue='0 0.3 1'/>
<fieldValue name='precisionvalue='1'/>
<fieldValue name='translationvalue='-0.04 0.04 0.0'/>
</ProtoInstance>
<!-- ProjectileInterpolator ROUTEs:  [from SliderVelocity.currentValueFloat to set_Vi ] [from SliderAngle.currentValueFloat to set_theta ] [from Timer.fraction_changed to set_fraction ] [from value_changed to ValueDisplayer.setTextValues ] [from value_changed to BallTransform.set_translation ] -->
<ProtoInstance name='ProjectileInterpolatorDEF='ProjectileInterpolator'/>
<ROUTE fromNode='SliderVelocityfromField='currentValueFloattoNode='ProjectileInterpolatortoField='set_Vi'/>
<ROUTE fromNode='SliderAnglefromField='currentValueFloattoNode='ProjectileInterpolatortoField='set_theta'/>
<Transform>
<Group DEF='HUDGroup'>
<Collision enabled='false'>
<!-- HudProx ROUTEs:  [from position_changed to HudTransform.set_translation ] [from orientation_changed to HudTransform.set_rotation ] [self-route from position_changed to center ] -->
<ProximitySensor DEF='HudProxsize='1000000 1000000 1000000'/>
<!-- HudTransform ROUTEs:  [from HudProx.position_changed to set_translation ] [from HudProx.orientation_changed to set_rotation ] -->
<Transform DEF='HudTransform'>
<Transform translation='0.05 0.06 -0.2'>
<Transform DEF='TrajectoryTextTransform'>
<Shape>
<Text DEF='RangeTextstring='"Range 0.0"solid='false'>
<FontStyle size='0.01style='BOLD'/>
</Text>
<Appearance>
<Material diffuseColor='0.9 0.7 0.0'/>
</Appearance>
</Shape>
</Transform>
<Transform translation='0.0 -0.015 0.0'>
<Shape>
<Text DEF='HeightTextstring='"Max Height 0.0"solid='false'>
<FontStyle size='0.01style='BOLD'/>
</Text>
<Appearance>
<Material diffuseColor='0 1 0'/>
</Appearance>
</Shape>
</Transform>
</Transform>
</Transform>
</Collision>
</Group>
</Transform>
<ROUTE fromNode='HudProxfromField='position_changedtoNode='HudTransformtoField='set_translation'/>
<ROUTE fromNode='HudProxfromField='position_changedtoNode='HudProxtoField='center'/>
<ROUTE fromNode='HudProxfromField='orientation_changedtoNode='HudTransformtoField='set_rotation'/>
<!-- ValueDisplayer ROUTEs:  [from ProjectileInterpolator.value_changed to setTextValues ] [from HitSensor.isActive to reset ] -->
<Script DEF='ValueDisplayerdirectOutput='true'>
<field name='setTextValuestype='SFVec3faccessType='inputOnly'/>
<field name='resettype='SFBoolaccessType='inputOnly'/>
<field name='RangeTexttype='SFNodeaccessType='initializeOnly'>
<Text USE='RangeTextsolid='false'/>
</field>
<field name='HeightTexttype='SFNodeaccessType='initializeOnly'>
<Text USE='HeightTextsolid='false'/>
</field>
<![CDATA[
      ecmascript:
var maxValue;

function initialize() {
   maxValue = 0;
}

function setTextValues(values, timeEvent) {
   var precision = 2;
   RangeText.string[0] ='Range            ' + roundOff(values[0], precision);
   if(values[1] > maxValue) {
      maxValue = roundOff(values[1], precision);
      Browser.print ('maximum' + maxValue);
   }

   Browser.print ('values' + values[1]);
   HeightText.string[0] ='Max Height   ' + maxValue;
}

function reset(bool, eventTime) {
   maxValue = 0;
}

//A function to round the values regarding to given precision.
function roundOff(value, precision) {

   var result;
   var isNegative = false;
   var wholeInt = Math.round(value * Math.pow(10, precision));
 
   //Negative numbers creates exceptional condition, therefor they are converted
   //to positive values.
   if(wholeInt < 0) {
      wholeInt = -wholeInt;
      isNegative = true;
   }

   var whole = wholeInt.toString();
   
   var decPoint = whole.length - precision;
   
   //Exception when precision is bigger than the string length   
   if(decPoint < 0) {
      i = -decPoint;
      for(i; i > 0; i--) {  
         whole ='0' + whole;
      }

      //Calculate decPoint according to new string expanded with 0s      
      decPoint = whole.length - precision;
   }

   if(whole !='0') {
      //Put the decimal point on the appropriate place
      result = whole.substring(0, decPoint);
      result +='.';
      result += whole.substring(decPoint, whole.length);
   }
   else { //If the string is'0', then result is'0'
      result = whole;
   }
   
   //Negative numbers are altered.
   if(isNegative) {
      result ='-' + result;
   }
   //Convert the String value to Float.
   resultFloat = parseFloat(result); 
  
  
   return resultFloat;
  
}
   
    
    
]]>
</Script>
<ROUTE fromNode='ProjectileInterpolatorfromField='value_changedtoNode='ValueDisplayertoField='setTextValues'/>
<Transform translation='0.0 -0.7 0.0'>
<Collision>
<Shape>
<Appearance> </Appearance>
<ElevationGrid xDimension='4xSpacing='40zDimension='2zSpacing='25height='-0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75 -0.75'/>
</Shape>
</Collision>
</Transform>
<Transform translation='0 0 12.5'>
<!-- BallTransform ROUTE:  [from ProjectileInterpolator.value_changed to set_translation ] -->
<Transform DEF='BallTransform'>
<Shape>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Sphere radius='1.5'/>
</Shape>
<Viewpoint description='BallViewposition='0 10 70fieldOfView='0.7854'/>
<!-- HitSensor ROUTEs:  [from touchTime to Timer.set_startTime ] [from isActive to ValueDisplayer.reset ] -->
<TouchSensor DEF='HitSensor'/>
</Transform>
</Transform>
<!-- Timer ROUTEs:  [from HitSensor.touchTime to set_startTime ] [from fraction_changed to ProjectileInterpolator.set_fraction ] -->
<TimeSensor DEF='TimercycleInterval='3.5'/>
<ROUTE fromNode='TimerfromField='fraction_changedtoNode='ProjectileInterpolatortoField='set_fraction'/>
<ROUTE fromNode='HitSensorfromField='touchTimetoNode='TimertoField='set_startTime'/>
<ROUTE fromNode='HitSensorfromField='isActivetoNode='ValueDisplayertoField='reset'/>
<ROUTE fromNode='ProjectileInterpolatorfromField='value_changedtoNode='BallTransformtoField='set_translation'/>
<!-- TimeConverter ROUTE:  [from TimeCycle.currentValueFloat to setTime ] -->
<Script DEF='TimeConverterdirectOutput='true'>
<field name='TimerNodetype='SFNodeaccessType='initializeOnly'>
<TimeSensor USE='Timer'/>
</field>
<field name='setTimetype='SFFloataccessType='inputOnly'/>
<![CDATA[
      ecmascript:
function initialize() {
}

function setTime(inputTime, timeEvent) {
   TimerNode.cycleInterval = inputTime;
}
   
    
]]>
</Script>
<ROUTE fromNode='TimeCyclefromField='currentValueFloattoNode='TimeConvertertoField='setTime'/>
</Scene>
</X3D>
<!--

Index for ExternProtoDeclare definitions: ProjectileSliderBar, ProjectileInterpolator
Index for DEF nodes: BallTransform, FirstView, HeightText, HitSensor, HUDGroup, HudProx, HudTransform, ProjectileInterpolator, RangeText, SliderAngle, SliderVelocity, TimeConverter, TimeCycle, Timer, TrajectoryTextTransform, ValueDisplayer
Index for Viewpoint images: FirstView, Viewpoint_2
-->

<!-- Tag color codes (X3D, XML terminology): <Node DEF='idName' field='value'/> <Element DEF='idName' attribute='value'/> <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->