示例#1
0
文件: Plane.hpp 项目: atria-soft/etk
			/**
			 * @brief Set the plane with 3 points in the space
			 * @param[in] _p0 First point
			 * @param[in] _p1 Second point
			 * @param[in] _p2 Thrid point
			 */
			void setFromPoints(const etk::Vector3D<T>& _p0,
			                   const etk::Vector3D<T>& _p1,
			                   const etk::Vector3D<T>& _p2) {
				m_normal = (_p1 - _p0).cross(_p2 - _p0);
				m_normal.normalize();
				calculateIntercept(_p0);
			}
示例#2
0
int cTrendLine::Create(flarb_mapbuilder::MapImage &msg, int x, int y)
{
	yAxisValuesSum = 0;
	xAxisValuesSum = 0;
	//arrray Max points from laser
	int yAxisValues[1081];
    int xAxisValues[1081];
	int ptr = 0;

	//from here till line 52 must be rebuild to levels
	//now he tries the whole level(Image)	
	
// Iterator
	vector<uint8_t>::const_iterator itr = msg.data.begin();
	
	// Write the image to the buffer
	for( int y = 0; y < 512; y++)
	{
		for( int x = 0; x < (512 / 8); x++)
		{
			//Get value and advance the iterator
			int val = *(itr);
			itr++;
			
			//note all the x and y locations and count them
			for(int i = 0; i < 7; i++){
				if(1 == (val & ( 1 << i )))
				{
					yAxisValues[ptr] = y;
					yAxisValuesSum += y;
					xAxisValues[ptr] = x * 8;
					xAxisValuesSum += x;
					ptr++;
				}		
			}			
		}
	}
	
	//unnecessary pointer
	count = ptr;
	//sum of x and y
	xxSum = 0;
    xySum = 0;
	
	
	for (int i = 0; i < count; i++)
    {
        xySum += ( xAxisValues[i] * yAxisValues[i] );
        xxSum += ( xAxisValues[i] * xAxisValues[i] );
    }

	Slope = calculateSlope();
    Intercept = calculateIntercept();
    Start = calculateStart();
    End = calculateEnd();
    return 1;
}