<?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='Immersive' version='3.0 xmlns: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 2019'/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorArena.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<WorldInfo title='ProjectileInterpolatorArena.x3d'/>
<ExternProtoDeclare name='ProjectileSliderBar'
  url=' "ProjectileSliderBarPrototype.wrl#ProjectileSliderBar" "https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileSliderBarPrototype.wrl#ProjectileSliderBar" "ProjectileSliderBarPrototype.x3d#ProjectileSliderBar" "https://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" "https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileInterpolatorPrototype.wrl#ProjectileInterpolator" "ProjectileInterpolatorPrototype.x3d#ProjectileInterpolator" "https://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 150'/>
<Background groundAngle='1.309 1.570796groundColor='0 0 0skyAngle='1.309 1.571skyColor='0 0 0'
  backUrl=' "urn:web3d:media:textures/panoramas/space_1_back.jpg" "space_1_back.jpg" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_back.jpg" "https://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" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_bottom.jpg" "https://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" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_front.jpg" "https://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" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_left.jpg" "https://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" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_right.jpg" "https://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" "https://www.web3d.org/WorkingGroups/media/textures/panoramas/space_1_top.jpg" "https://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'/>
<!-- ROUTE information for SliderVelocity node:  [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>
<!-- ROUTE information for SliderAngle node:  [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>
<!-- ROUTE information for TimeCycle node:  [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>
<!-- ROUTE information for ProjectileInterpolator node:  [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 bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Group DEF='HUDGroupbboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Collision enabled='falsebboxCenter='0 0 0bboxSize='-1 -1 -1'>
<!-- ROUTE information for HudProx node:  [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'/>
<!-- ROUTE information for HudTransform node:  [from HudProx.position_changed to set_translation ] [from HudProx.orientation_changed to set_rotation ] -->
<Transform DEF='HudTransformbboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Transform translation='0.05 0.06 -0.2bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Transform DEF='TrajectoryTextTransformbboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Shape bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Text DEF='RangeTextstring='"Range 0.0"'>
<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.0bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Shape bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Text DEF='HeightTextstring='"Max Height 0.0"'>
<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'/>
<!-- ROUTE information for ValueDisplayer node:  [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='RangeText'/>
</field>
<field name='HeightTexttype='SFNodeaccessType='initializeOnly'>
<Text USE='HeightText'/>
</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.0bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Collision enabled='truebboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Shape bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Appearance> </Appearance>
<ElevationGrid xDimension='4xSpacing='40zSpacing='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.5bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<!-- ROUTE information for BallTransform node:  [from ProjectileInterpolator.value_changed to set_translation ] -->
<Transform DEF='BallTransformbboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Shape bboxCenter='0 0 0bboxSize='-1 -1 -1'>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Sphere radius='1.5'/>
</Shape>
<Viewpoint description='BallViewposition='0 10 70'/>
<!-- ROUTE information for HitSensor node:  [from touchTime to Timer.set_startTime ] [from isActive to ValueDisplayer.reset ] -->
<TouchSensor DEF='HitSensor'/>
</Transform>
</Transform>
<!-- ROUTE information for Timer node:  [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'/>
<!-- ROUTE information for TimeConverter node:  [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 : ProjectileInterpolator, ProjectileSliderBar

Index for DEF nodes : BallTransform, FirstView, HeightText, HitSensor, HUDGroup, HudProx, HudTransform, ProjectileInterpolator, RangeText, SliderAngle, SliderVelocity, TimeConverter, TimeCycle, Timer, TrajectoryTextTransform, ValueDisplayer

Index for Viewpoint images : Viewpoint_1, FirstView
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
    <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->