<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN"   "http://www.web3d.org/specifications/x3d-3.1.dtd">
<X3D profile='Immersiveversion='3.1xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>
<head>
<meta name='titlecontent='Arc2dComponentPrototype.x3d'/>
<meta name='descriptioncontent='X3D Geometry2D component node, implemented as prototype for backwards compatibility with VRML 97. Arc2D specifies a 2D linear circular arc.'/>
<meta name='authorscontent='Christos Kalogrias, Don Brutzman, Ken Curtin, Duane Davis'/>
<meta name='createdcontent='14 November 2003'/>
<meta name='modifiedcontent='20 September 2007'/>
<meta name='referencecontent=' http://www.web3d.org/spec_editors/abstract/Part01/components/geometry2D.html '/>
<meta name='subjectcontent='Geometry2D component node (Arc2D)'/>
<meta name='identifiercontent=' http://www.web3d.org/x3d/content/examples/Basic/development/Arc2dComponentPrototype.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent='../license.html'/>
</head>
<!--

Index for ProtoDeclare definition: Arc2D
Index for DEF nodes: Arc2dToFaceSet3d, Arc3DPoints, ArcIndexPoints
-->
<Scene>
<!-- ==================== -->
<ProtoDeclare name='Arc2D'>
<ProtoInterface>
<field name='startAngletype='SFFloatvalue='0accessType='initializeOnly'/>
<field name='endAngletype='SFFloatvalue='1.5707963265accessType='initializeOnly'/>
<field name='radiustype='SFFloatvalue='1accessType='initializeOnly'/>
<field name='metadatatype='SFNodeaccessType='inputOutput'
 appinfo='Metadata node only'/>
</ProtoInterface>
<ProtoBody>
<!-- Only the first node counts as the node type of a prototype. This node must be a geometry node. -->
<!-- ArcIndexPoints ROUTE:  [from Arc2dToFaceSet3d.arcIndexSet3d to set_coordIndex ] -->
<IndexedLineSet DEF='ArcIndexPoints'>
<!-- Arc3DPoints ROUTE:  [from Arc2dToFaceSet3d.arcSet3d to point ] -->
<Coordinate DEF='Arc3DPoints'/>
</IndexedLineSet>
<!-- Any nodes after initial node in a ProtoBody is not rendered. -->
<Group>
<IS>
<connect nodeField='metadataprotoField='metadata'/>
</IS>
<!-- Arc2dToFaceSet3d ROUTEs:  [from arcSet3d to Arc3DPoints.point ] [from arcIndexSet3d to ArcIndexPoints.set_coordIndex ] -->
<Script DEF='Arc2dToFaceSet3d'>
<field name='startAngletype='SFFloataccessType='initializeOnly'/>
<field name='endAngletype='SFFloataccessType='initializeOnly'/>
<field name='radiustype='SFFloataccessType='initializeOnly'/>
<field name='arcSet3dtype='MFVec3faccessType='outputOnly'/>
<field name='arcIndexSet3dtype='MFInt32accessType='outputOnly'/>
<IS>
<connect nodeField='startAngleprotoField='startAngle'/>
<connect nodeField='endAngleprotoField='endAngle'/>
<connect nodeField='radiusprotoField='radius'/>
</IS>
<![CDATA[
            ecmascript:

function initialize()
{
   numOfPoints = 100;

   if (radius < 0)
   {
      Browser.print ('[Arc2D] Warning:  invalid value, radius=' + value + ' must instead be >= 0');
   }

   if ((startAngle < 0) || (startAngle >= 2 * Math.PI))
   {
      Browser.print ('[Arc2D] Warning: startAngle=' + startAngle + ' must be within range [0..2pi)');
   }

   if ((endAngle < 0) || (endAngle >= 2 * Math.PI))
   {
      Browser.print ('[Arc2D] Warning: endAngle=' + endAngle + ' must be within range [0..2pi)');
   }

   // equal startAngle, endAngle means draw full circle.
   // high out-of-range endAngle is OK for local computation.
   if (startAngle >= endAngle)
      endAngle += (2 * Math.PI);

   differAng = Math.abs((endAngle - startAngle))/numOfPoints;

   for (i = 0; i <= numOfPoints; i++)
   {
      arcSet3d[i] = new SFVec3f (radius * Math.cos(startAngle + i * differAng), radius * Math.sin(startAngle + i * differAng), 0.0);
      arcIndexSet3d[i] = i;
   }

} // initialize
          
          
]]>
</Script>
<ROUTE fromNode='Arc2dToFaceSet3dfromField='arcSet3dtoNode='Arc3DPointstoField='point'/>
<ROUTE fromNode='Arc2dToFaceSet3dfromField='arcIndexSet3dtoNode='ArcIndexPointstoField='set_coordIndex'/>
</Group>
</ProtoBody>
</ProtoDeclare>
</Scene>
</X3D>
<!--

Index for ProtoDeclare definition: Arc2D
Index for DEF nodes: Arc2dToFaceSet3d, Arc3DPoints, ArcIndexPoints
-->

<!-- Tag color codes: <Node DEF='idName' attribute='value'/> <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->