<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "https://www.web3d.org/specifications/x3d-3.1.dtd">
<X3D profile='Immersive'  version='3.1 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' https://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='creatorcontent='Christos Kalogrias, Don Brutzman, Ken Curtin, Duane Davis'/>
<meta name='createdcontent='14 November 2003'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name='referencecontent=' https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/geometry2D.html '/>
<meta name='subjectcontent='Geometry2D component node (Arc2D)'/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/development/Arc2dComponentPrototype.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: Arc2dToFaceSet3d, Arc3DPoints, ArcIndexPoints

Index for ProtoDeclare definition: Arc2D
-->
<Scene>
<!-- ==================== -->
<WorldInfo title='Arc2dComponentPrototype.x3d'/>
<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. -->
<!-- ROUTE information for ArcIndexPoints node:  [from Arc2dToFaceSet3d.arcIndexSet3d to set_coordIndex ] -->
<IndexedLineSet DEF='ArcIndexPoints'>
<!-- ROUTE information for Arc3DPoints node:  [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>
<!-- ROUTE information for Arc2dToFaceSet3d node:  [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.println ('[Arc2D] Warning:  invalid value, radius=' + value + ' must instead be >= 0');
   }

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

   if ((endAngle < 0) || (endAngle >= 2 * Math.PI))
   {
      Browser.println ('[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=' Arc2dToFaceSet3d' fromField='arcSet3d' toNode=' Arc3DPoints' toField='point'/>
< ROUTE  fromNode=' Arc2dToFaceSet3d' fromField='arcIndexSet3d' toNode=' ArcIndexPoints' toField='set_coordIndex'/>
</Group>
</ProtoBody>
</ProtoDeclare>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: Arc2dToFaceSet3d, Arc3DPoints, ArcIndexPoints

Index for ProtoDeclare definition: Arc2D
-->

Event Graph ROUTE Table with 2 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

Arc2dToFaceSet3d
Script
arcSet3d
MFVec3f

ROUTE
event to
(1)
Arc3DPoints
Coordinate
point
MFVec3f
Arc2dToFaceSet3d
Script
arcIndexSet3d
MFInt32

ROUTE
event to
(1)
ArcIndexPoints
IndexedLineSet
set_coordIndex
MFInt32


-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/Basic/development/Arc2dComponentPrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/Arc2dComponentPrototype.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->