Ejemplo n.º 1
0
		//Keep track of nearest object by setting others to null.
		private void TrackNearestObject ( float distance, ref float nearestDistance, Cell returnedCell, ref Cell nearestCell, DistalSynapse returnedDistalSynapse, ref DistalSynapse nearestDistalSynapse, ProximalSynapse returnedProximalSynapse, ref ProximalSynapse nearestProximalSynapse )
		{
			if (distance < nearestDistance)
			{
				nearestDistance = distance;

				if (returnedCell != null)
				{
					nearestCell = returnedCell;
					nearestDistalSynapse = null;
					nearestProximalSynapse = null;
				}
				if (returnedDistalSynapse != null)
				{
					nearestCell = null;
					nearestDistalSynapse = returnedDistalSynapse;
					nearestProximalSynapse = null;
				}
				if (returnedProximalSynapse != null)
				{
					nearestCell = null;
					nearestDistalSynapse = null;
					nearestProximalSynapse = returnedProximalSynapse;
				}
			}
		}
Ejemplo n.º 2
0
		private float PickProximalSynapseConnections ( Ray ray, Column column, ref ProximalSynapse returnedProximalSynapse )
		{
			float intersectDistance = float.MaxValue;
			float minDistance = float.MaxValue;

			returnedProximalSynapse = null;

			// Draw Connections if existing
			if (column.IsDataGridSelected || (Simulation3D.Form.ShowSpatialLearning && column.ActiveState[Global.T]))
			{
				Vector3 rayP1 = ray.Position;
				Vector3 rayP2 = rayP1 + ray.Direction;

				foreach (ProximalSynapse synapse in column.ProximalSegment.Synapses)
				{
					synapse.mouseOver = false;

					if (column.Statistics.StepCounter > 0)
					{
						//var proximalSynapse = synapse as ProximalSynapse;

						// Get the two vectors to draw line between
						var startPosition = new Vector3 ( column.PositionInRegion.X, 0, column.PositionInRegion.Y + _zHtmRegion );

						// Get input source position
						int x = synapse.InputSource.X;
						int y = (int)_yHtmPlane;
						int z = synapse.InputSource.Y;
						var endPosition = new Vector3 ( x, y, z + _zHtmPlane );
							
						bool intersect;
						Vector3 Line1ClosestPt = new Vector3 ();
						Vector3 Line2ClosestPt = new Vector3 ();
						intersect = Math3D.ClosestPointsLineSegmentToLine ( out Line1ClosestPt, out Line2ClosestPt, startPosition, endPosition, rayP1, rayP2, 0.1f, out intersectDistance );

						if (intersect && intersectDistance < minDistance)
						{
							minDistance = intersectDistance;
							returnedProximalSynapse = synapse;
						}
					}
				}
			}

			return minDistance;
		}
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new synapse for this segment attached to the specified input cell.
 /// </summary>
 /// <param name="inputSource">the input source of the synapse to create.</param>
 /// <param name="initialPermanence">the initial permanence of the synapse.</param>
 internal void CreateSynapse(InputCell inputSource, double initialPermanence)
 {
     var newSynapse = new ProximalSynapse(this, inputSource, (float)initialPermanence);
     this.Synapses.Add(newSynapse);
 }
Ejemplo n.º 4
0
		/// <summary>
		/// Helper Method to get color from proximal synapse state
		/// </summary>
		/// <param name="proximalSynapse"></param>
		/// <param name="color"></param>
		/// <param name="alphaValue"></param>
		private void GetColorFromProximalSynapse ( ProximalSynapse proximalSynapse, out Color color, out float alphaValue )
		{
			color = this._dictionaryProximalSynapseColors[HtmProximalSynapseColors.Default].HtmColor;
			alphaValue = .1f; // All conditions can be false. 
			Simulation3DForm visualizerForm = Simulation3D.Form;

			try
			{
				if (proximalSynapse.IsActive ( Global.T ))
				{
					if (proximalSynapse.IsConnected ())	// Active & connected.
					{
						//this._connectionLine.SetUpVertices ( startPosition, endPosition, Color.Green );
						{
							alphaValue = 1f;
							color = this._dictionaryProximalSynapseColors[HtmProximalSynapseColors.ActiveConnected].HtmColor;
						}
					}
					else	// Active.
					{
						//this._connectionLine.SetUpVertices ( startPosition, endPosition, Color.Orange );
						alphaValue = 1f;
						color = this._dictionaryProximalSynapseColors[HtmProximalSynapseColors.Active].HtmColor;
					}
				}
				else // Not active.
				{
					//this._connectionLine.SetUpVertices ( startPosition, endPosition, Color.White );
					alphaValue = 1f;
					color = this._dictionaryProximalSynapseColors[HtmProximalSynapseColors.Default].HtmColor;
				}

				//selected
				if (proximalSynapse.mouseSelected)
				{
					color = selectedColor;
					alphaValue = 1f;
					//color = this._dictionaryProximalSynapseColors[HtmProximalSynapseColors.MouseSelected].HtmColor;
				}
				//mouseOver
				if (proximalSynapse.mouseOver)
				{
					color = mouseOverColor;
					alphaValue = 1f;
					//color = this._dictionaryProximalSynapseColors[HtmProximalSynapseColors.MouseOver].HtmColor;
				}
			}
			catch (Exception)
			{

			}
		}
Ejemplo n.º 5
0
        /// <summary>
        /// Create a new synapse for this segment attached to the specified input cell.
        /// </summary>
        /// <param name="inputSource">the input source of the synapse to create.</param>
        /// <param name="initialPermanence">the initial permanence of the synapse.</param>
        internal void CreateSynapse(InputCell inputSource, double initialPermanence)
        {
            var newSynapse = new ProximalSynapse(this, inputSource, (float)initialPermanence);

            this.Synapses.Add(newSynapse);
        }