#VRML V2.0 utf8					
# Axes view-controller prototype a component in a 3D data plotting application 
#   for polar grids 
#     - two circular controller grids at z=+1 and z=-1 
#     - polar circles are at .2, .4, .6, .8 and 1.0 distance 
#     - with 12 longitudes lines 
# Kurt A. Fisher fisherka@csolutions.net  beginner level VRML coder
# 1/2004

#     The limits of this graph box are set dynamically in the prototype.  
#     The axes, the axes labels and the viewpoints are scaled to a 1 unit size. 
#     A transformation resizes the axes to fit the needed size for the world.  
#
#     VRML normally plots with "z" pointing up out of the screen 
#       and the x-y axis plotting on the flat screen. 
#       The positive x-axis is to the right.
#       The positive y-axis is to the top. 
#
#     For display in normal galactic plane (z at top with positive x 
#       pointing out of the screen and towards the galactic center), 
#       A two-fold rotation is used to rotate the axis and world to the 
#       desired normal orientation. 

#       This rotation into normal galactic display is accomplished with 
#       two fold 90 degree rotations - once around the z axis and once around 
#       the x-axis.  Once these rotations are applied, x, y, z in a standard 
#       VRML rotation, if reference from outside the rotated object, are: 
#		Before		x	y	z
#		After		y	z	x

#       Tickmarks are at scaled 0.10 * scaleAxis[0] / scaleData[0] objects
#       E.g. - 0.10 & 6x axis scale up / 2x object scale up = .3 scale 

#  This application was developed for use in triaxial position modeling 
#   of astronomical objects.  Occassional coding references may reflect this bias. 

#  Objects used: 
#	None -  Axes_Ctrl is a root object 

#   Objects outline
#	Controller 		->Control_Panel -> Views 	
#			-> Axes_ctrl_polar view (this file)	
#			-> Data views (Data_Sets) ->
#				Model ->
#				DataSet (external file) -> Plotting object types (lib directory) 

PROTO AXES_CTRL [ 
	exposedField SFVec3f 	scaleAxis			2.0 2.0 2.0 				# Tickmarks are at scaled 0.10 * scaleAxis[0] / scaleData[0] objects 
	exposedField SFColor	axisColor			0.0 0.0 0.0				#  color for the fonts and axes 
	exposedField SFVec3f	scaleTickMarkSize		0.005 0.005 0.005 			#  scale size of sphere tick marks on axes 
											#        use z-axis vector = 0.0001 for one grid ( 1.0 1.0 1.0 .0001 ) and >0 to split into two grids ( 1 1 1 )
	exposedField SFRotation	convertCoordinateSys	0.000 0.000 0.000 0.000		#  Rotate the entire axes object to a new coordinate system; usually leave as 0 0 0 0.00
#							#      E.g. convert frame between galactic, equatorial and horizon systems 
] # end PROTO Fields
# Begin PROTO OBJECT
{

Transform  { 		# rotate the entire object to new coordinate system 
#			x	y	z	rot
	rotation IS convertCoordinateSys
	children [

# BEGIN AXES OBJECT 
# Two-fold rotation of world to normal galactic presentation - looking down postive x axis l=0 to Orion at l=180 
DEF firstWorldRotationX Transform { 
	rotation 1.0 0.0 0.0 -1.571 # first rotation of world around x-axis
	children [

DEF secondWorldRotationZ Transform { 
	rotation 0.0 0.0 1.0 -1.571 # second rotation of world around z-axis
	children [

# SPHERICAL GRID WITH AUTOMATIC SCALING 
DEF XYZaxis Transform {	
			center 0.0 0.0 0.0 
			translation 0.0 0.0 0.0
			scale IS scaleAxis
	children [

# Adjust the inline object scale to a unity size 
DEF setObjSizeOne Transform { 
			center 0.0 0.0 0.0 
			translation 0.0 0.0 0.0
			scale 1.0 1.0 1.0 

	children [

# Make the first polar grid at z=+1 
Transform { 		
	translation 0.0 0.0 1.0 
	children [ 

DEF PolarGrid Group { 
	children [

#  The star shapes in center of world 
Shape {
	appearance Appearance {
		material Material {
			emissiveColor IS axisColor
		}
	}
	geometry IndexedLineSet {
		coord Coordinate {
			point [
0.000,0.000,0.000, # Index 0 Long 0 Lat 0 Origin
1.000,0.000,0.000, # Index 1 Long 0 Lat 0
0.866,-0.500,0.000, # Index 2 Long 330 Lat 0
0.500,-0.866,0.000, # Index 3 Long 300 Lat 0
0.000,-1.000,0.000, # Index 4 Long 270 Lat 0
-0.500,-0.866,0.000, # Index 5 Long 240 Lat 0
-0.866,-0.500,0.000, # Index 6 Long 210 Lat 0
-1.000,0.000,0.000, # Index 7 Long 180 Lat 0
-0.866,0.500,0.000, # Index 8 Long 150 Lat 0
-0.500,0.866,0.000, # Index 9 Long 120 Lat 0
0.000,1.000,0.000, # Index 10 Long 90 Lat 0
0.500,0.866,0.000, # Index 11 Long 60 Lat 0
0.866,0.500,0.000, # Index 12 Long 30 Lat 0
			]  # end Point
		} # end Coordinate 
		coordIndex [
# Line connections to form star 
0	,	1	,	-1	,
0	,	2	,	-1	,
0	,	3	,	-1	,
0	,	4	,	-1	,
0	,	5	,	-1	,
0	,	6	,	-1	,
0	,	7	,	-1	,
0	,	8	,	-1	,
0	,	9	,	-1	,
0	,	10	,	-1	,
0	,	11	,	-1	,
0	,	12	,	-1	,

		]  # end coordIndex
	} # end IndexLine geometry 
} # end Shape 

#  Make tick marks on the lines - hard coded to 10 marks 
#  TICK MARKS ON AXIS LINES 
#  Hard-coded scaling in 10ths using individual spheres
DEF TickMarks Group {
	children [ 

# Define the first tickmark 
DEF TickMark Transform {
	translation 	-0.900	0.000	0.000
	scale IS scaleTickMarkSize
	children [
		DEF TickMarkSphere Shape {	
					appearance Appearance {					
					material Material {				
#						diffuseColor IS axisColor
						emissiveColor IS axisColor

						} # end Material 				
					} # end Appearance 
					geometry Sphere { }
				} # end Shape TickMarkSphere 
		] # end of children Transform scale TickMark 
	} # end of Transform TickMark 

# Re-use the tickmark definition 
	#  X-Axis
Transform { translation -0.100 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.200 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.300 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.400 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.500 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.600 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.700 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.800 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -0.900 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation -1.000 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.100 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.200 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.300 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.400 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.500 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.600 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.700 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.800 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +0.900 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation +1.00 0.000 0.000  scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
	#  Y-Axis
Transform { translation 0.000 -0.100 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.200 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.300 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.400 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.500 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.600 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.700 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.800 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -0.900 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 -1.000 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.100 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.200 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.300 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.400 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.500 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.600 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.700 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.800 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +0.900 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }
Transform { translation 0.000 +1.000 0.000 scale IS scaleTickMarkSize children [ USE TickMarkSphere ] }

	] # end children Group TickMarks
} # end Group TickMarks

#  Polar circle ring at 1.0 
DEF PolarCircle Shape { 
	appearance Appearance { 
		material Material { 
			emissiveColor IS axisColor
		} # end Material
	} # end Appearance
	geometry IndexedLineSet {
		coord Coordinate {
			point [
1.000,0.000,0.000, # Index 0 Long 0 Lat 0
0.966,-0.259,0.000, # Index 1 Long 345 Lat 0
0.866,-0.500,0.000, # Index 2 Long 330 Lat 0
0.707,-0.707,0.000, # Index 3 Long 315 Lat 0
0.500,-0.866,0.000, # Index 4 Long 300 Lat 0
0.259,-0.966,0.000, # Index 5 Long 285 Lat 0
0.000,-1.000,0.000, # Index 6 Long 270 Lat 0
-0.259,-0.966,0.000, # Index 7 Long 255 Lat 0
-0.500,-0.866,0.000, # Index 8 Long 240 Lat 0
-0.707,-0.707,0.000, # Index 9 Long 225 Lat 0
-0.866,-0.500,0.000, # Index 10 Long 210 Lat 0
-0.966,-0.259,0.000, # Index 11 Long 195 Lat 0
-1.000,0.000,0.000, # Index 12 Long 180 Lat 0
-0.966,0.259,0.000, # Index 13 Long 165 Lat 0
-0.866,0.500,0.000, # Index 14 Long 150 Lat 0
-0.707,0.707,0.000, # Index 15 Long 135 Lat 0
-0.500,0.866,0.000, # Index 16 Long 120 Lat 0
-0.259,0.966,0.000, # Index 17 Long 105 Lat 0
0.000,1.000,0.000, # Index 18 Long 90 Lat 0
0.259,0.966,0.000, # Index 19 Long 75 Lat 0
0.500,0.866,0.000, # Index 20 Long 60 Lat 0
0.707,0.707,0.000, # Index 21 Long 45 Lat 0
0.866,0.500,0.000, # Index 22 Long 30 Lat 0
0.966,0.259,0.000, # Index 23 Long 15 Lat 0
			] # end Point 
		}  # end Coordinates 
		coordIndex [
# Line connections to form star 
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,0,-1
		]  # end coordIndex 
	} # end IndexedLineSet 
} # end Shape 

#  Polar circle ring at 0.8 
Transform {  scale 0.8 0.8 0.8 children [  Shape { } USE PolarCircle ] } 

#  Polar circle ring at 0.6 
Transform {  scale 0.6 0.6 0.6 children [  Shape { } USE PolarCircle ] } 

#  Polar circle ring at 0.4 
Transform {  scale 0.4 0.4 0.4 children [  Shape { } USE PolarCircle ] } 

#  Polar circle ring at 0.2 
Transform {  scale 0.2 0.2 0.2 children [  Shape { } USE PolarCircle ] } 

	] # end children Group Polar_Grid object 
}  # end Group Polar_Grid object 

	] # end children Transform Make the first polar grid at z=+1 
}  # end Make the first polar grid at z=+1 

#  Make the second grid at z=-1 
Transform { 		
	translation 0.0 0.0 -1.0 
	children [ 

Group { } USE PolarGrid 

	] # end children Transform Make the first polar grid at z=-1 
}  # end Make the first polar grid at z=-1 

	] # end children Transform Scale Object to Unity Size 
} # end Transform Scale Object to Unity Size 

	] # end children Transform Group Axes with scaling 
} # end Transform Group Axes with scaling 

	] # end children secondWorldRotationZ - around Z axis 
} # end Transform secondWorldRotationZ around Z axis 

	] # end children firstWorldRotationX - around X axis 
} # end Transform firstWorldRotationX around X axis 
# END OF AXES AND LABELS OBJECT 

	] # children Transform Convert to new coordinate system
} # end Transform Convert to new coordinate system 

 } # end PROTO OBJECT

