Exemple #1
0
	status_t decodeInputVector(string * fragment)
	{
		float inputValue;
		unsigned int node;
		std::string::size_type startPos;
		unsigned int inputNodeCount;
		vector<float> lineVector(
				inputNodeCount = ((nn*) theNetwork)->layerZeroWidth());

		startPos = 1;

#ifdef _DEBUG_
		cout << "Input Values,";
#endif

		for (node = 0; node < (inputNodeCount - 1); node++) //>
		{
			inputValue = nextFValue(fragment, startPos);
			lineVector[node] = inputValue;
#ifdef _DEBUG_
			cout << " Node " << node << ": " << inputValue;
#endif
		}
		inputValue = nextFValue(fragment, startPos, ')');
#ifdef _DEBUG_
		cout << " Node " << node << ": " << inputValue << "\n";
#endif
		lineVector[node] = inputValue;

		((nn*) theNetwork)->run(&lineVector, NULL, lineCount); // run immediately

		return SUCCESS;
	}
void EC_45DEGREE::Apply( EDIT_POINT& aHandle )
{
    // Current line vector
    VECTOR2I lineVector( aHandle.GetPosition() - m_constrainer.GetPosition() );
    double angle = lineVector.Angle();

    // Find the closest angle, which is a multiple of 45 degrees
    double newAngle = KiROUND( angle / ( M_PI / 4.0 ) ) * M_PI / 4.0;
    VECTOR2I newLineVector = lineVector.Rotate( newAngle - angle );

    aHandle.SetPosition( m_constrainer.GetPosition() + newLineVector );
}