#VRML V2.0 utf8
# X3D-to-VRML-97 XSL translation autogenerated by X3dToVrml97.xslt
# http://www.web3d.org/x3d/content/X3dToVrml97.xslt
# Generated using XSLT processor: SAXON 8.7 from Saxonica

# [X3D] VRML V3.0 utf8
# PROFILE Immersive
# [X3D] version=3.0
# [X3D] noNamespaceSchemaLocation=http://www.web3d.org/specifications/x3d-3.0.xsd
# [head]

# META "title" "Geometry2dComponentPrototypes.x3d"
# META "description" "X3D Geometry2D component nodes, implemented as prototypes for backwards compatibility with VRML 97. Arc2D specifies a 2D linear circular arc. ArcClose2D specifies a portion of a circle. Circle2D specifies a 2D circular line. Disk2D specifies a 2D circular disk. Polyline2D specifies 2D line segments. Polypoint2D specifies 2D points. Rectangle2D specifies a 2D rectangle. TriangleSet2D specifies 2D triangles. 2D nodes are considered particularly helpful for building user interfaces such as Heads-Up Displays (HUDs)."
# META "creator" "Christos Kalogrias, Don Brutzman, Ken Curtin, Duane Davis"
# META "created" "14 November 2003"
# META "modified" "25 February 2007"
# META "reference" "Geometry2dComponentExamples.x3d"
# META "reference" "http://www.web3d.org/spec_editors/abstract/Part01/components/geometry2D.html"
# META "subject" "Geometry2D component nodes (Arc2D ArcClose2D Circle2D Disk2D Polyline2D Polypoint2D Rectangle2D TriangleSet2D)"
# META "identifier" "http://www.web3d.org/x3d/content/examples/Basic/development/Geometry2dComponentPrototypes.x3d"
# META "generator" "X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit"
# META "license" "../license.html"
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
# 
# <html>
# <head>
# 			<title>NPS MOVES Software License</title>
# 			<meta name="description" content="NPS MOVES Software License" />
# 			<meta name="author" content="Donald P. Brutzman" />
# 			<meta name="created" content="4 March 2005" />
# 			<meta name="revised" content="17 December 2006" />
# 			<meta name="reference" content="http://www.oreilly.com/catalog/osfreesoft" />
# 			<meta name="reference" content="http://opensource.org/licenses/bsd-license.php" />
# 			<meta name="reference" content="http://xchat.movesinstitute.org/bugzilla/show_bug.cgi?id=32" />
# 			<link rel="icon" href="http://www.web3D.org/x3d/content/examples/images/X3DtextIcon16.png" title="X3D" type="image/png"/>
# </head>
# <body>
# <p>Copyright (c) 1995-2008 held by the author(s).  All rights reserved.</p>
# 
# <p>Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:</p>
# 
# <ul>
# 		<li>
#       Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     </li>  
# 		<li>	
# 			Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer
#       in the documentation and/or other materials provided with the
#       distribution.
# 		</li>	
# 		<li>	
#       Neither the names of the 
# 			<a href="http://www.nps.edu">Naval Postgraduate School (NPS)</a>
#       <a href="http://www.MovesInstitute.org">Modeling Virtual Environments and Simulation (MOVES) Institute</a>
#       nor the names of its contributors may be used to endorse or
#       promote products derived from this software without specific
#       prior written permission.
#     </li>
# </ul>			
# 
# <p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.</p>
# 
# </body>
# </html>

# [Scene] ========== ========== ==========

# ====================
PROTO ArcClose2D [
  field        SFFloat	startAngle 0
  field        SFFloat	endAngle 1.5707963265
  field        SFFloat	radius 1
  field        SFString	closureType "PIE"
   ### Error:  ProtoInterface <field name='solid'/> is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
field        SFBool	solid FALSE
   ### Error:  ProtoInterface <field name='metadata'/> is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
exposedField SFNode      metadata NULL    # [appinfo] Metadata node only

    # default NULL

] {
 ### Warning:  <ProtoDeclare name='ArcClose2D'/> ProtoBody child following first child will not be rendered, since the first child determines node type. (Authors can silence this warning by placing a comment as second child.)
  DEF ArcPointFaceIndex IndexedFaceSet {
    coord DEF ArcClose2DFaceCoordinate Coordinate {
    }
  }
  Group {
    children [
        DEF ArcClose2dToFaceSet3d Script {
          field        SFString	closureType IS closureType
          field        SFFloat	startAngle IS startAngle
          field        SFFloat	endAngle IS endAngle
          field        SFFloat	radius IS radius
          eventOut     MFVec3f	arcSet3d
          eventOut     MFInt32	pointIndex
                                                          
	url [ "javascript:
// ### X3D Browser.print() not supported by all VRML97 viewers, instead simply use print()


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

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

   if ((endAngle< 0) || (endAngle>= 2 * Math.PI))
   {
	print ('[ArcClose2D] 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 = endAngle + 2*Math.PI;

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

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

   k=0;
   if (closureType =='PIE')
       for ( i=0 ; i<numOfPoints ; i++)
       {
        	pointIndex[k]   = numOfPoints;
        	pointIndex[k+1] = i;
        	pointIndex[k+2] = i + 1;
        	pointIndex[k+3]   = numOfPoints;
        	pointIndex[k+4] = -1;
        k=k+5;
	}
   else
       for ( i=0 ; i<numOfPoints-1 ; i++)
       {
              pointIndex[k]   = 0;
              pointIndex[k+1] = i;
              pointIndex[k+2] = i + 1;
              pointIndex[k+3]   = 0;
              pointIndex[k+4] = -1;
        k=k+5;
	}

} // initialize
          
" ]
        }
    ]
  ROUTE ArcClose2dToFaceSet3d.arcSet3d TO ArcClose2DFaceCoordinate.point
  ROUTE ArcClose2dToFaceSet3d.pointIndex TO ArcPointFaceIndex.set_coordIndex
  }
}
# ArcClose2DUnfilled also provided since FillProperties not available in VRML 97
PROTO ArcClose2DUnfilled [
  field        SFFloat	startAngle 0
  field        SFFloat	endAngle 1.5707963265
  field        SFFloat	radius 1
  field        SFString	closureType "PIE"
   ### Error:  ProtoInterface <field name='solid'/> is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
field        SFBool	solid FALSE
   ### Error:  ProtoInterface <field name='metadata'/> is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
exposedField SFNode      metadata NULL    # [appinfo] Metadata node only

    # default NULL

] {
 ### Warning:  <ProtoDeclare name='ArcClose2DUnfilled'/> ProtoBody child following first child will not be rendered, since the first child determines node type. (Authors can silence this warning by placing a comment as second child.)
  DEF ArcPointLineIndex IndexedLineSet {
    coord DEF ArcClose2DLineCoordinate Coordinate {
    }
  }
  Group {
    children [
        DEF ArcClose2dToLineSet3d Script {
          field        SFString	closureType IS closureType
          field        SFFloat	startAngle IS startAngle
          field        SFFloat	endAngle IS endAngle
          field        SFFloat	radius IS radius
          eventOut     MFVec3f	arcSet3d
          eventOut     MFInt32	pointIndex
                                                          
	url [ "javascript:
// ### X3D Browser.print() not supported by all VRML97 viewers, instead simply use print()


function initialize()
{

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

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

   if ((endAngle< 0) || (endAngle>= 2 * Math.PI))
   {
	print ('[ArcCloseUnfilled2D] 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 = endAngle + 2*Math.PI;

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

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

   if (closureType =='CHORD')
   {
	for ( i=0 ; i<=numOfPoints +1 ; i++)
	{
        	if ( i == numOfPoints +1)
             		pointIndex[i] = 0.0;
        	else
             		pointIndex[i] = i;
	}
   }
   else
   {
	for ( i=0 ; i<=numOfPoints +1 ; i++)
	{
         pointIndex[i] = i;
	}
         pointIndex[i] = 0.0;
   }

} // initialize
          
" ]
        }
    ]
  ROUTE ArcClose2dToLineSet3d.arcSet3d TO ArcClose2DLineCoordinate.point
  ROUTE ArcClose2dToLineSet3d.pointIndex TO ArcPointLineIndex.set_coordIndex
  }
}
