当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix::Element方法代码示例

本文整理汇总了C++中Matrix::Element方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::Element方法的具体用法?C++ Matrix::Element怎么用?C++ Matrix::Element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix的用法示例。


在下文中一共展示了Matrix::Element方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Product

			Matrix Matrix::Product(const double & b) const{
				Matrix a = *this;
				for(int i = 0 ; i < 3 ; i++)
					for(int j = 0 ; j < 3 ; j++)
						a.Element(i,j,a.Element(i,j)*b);
				return a;
			}
开发者ID:francoisludewig,项目名称:MecaSolid,代码行数:7,代码来源:Matrix.cpp

示例2: Div

			Matrix Matrix::Div(const double & b) const{
				if(b == 0)
					throw(Error(1,"Dividing by 0 !",0));
				Matrix a = *this;
				for(int i = 0 ; i < 3 ; i++)
					for(int j = 0 ; j < 3 ; j++)
						a.Element(i,j,a.Element(i,j)/b);
				return a;
			}
开发者ID:francoisludewig,项目名称:MecaSolid,代码行数:9,代码来源:Matrix.cpp

示例3: TranslationMatrix

Matrix Matrix::TranslationMatrix()
{
	Matrix result = Identity();

	// copy last column into result
	for (int i = 0; i < 3; i++)
		result.Element(i,3) = Element(i,3);
	return result;
}
开发者ID:timothyandrew,项目名称:minigolf,代码行数:9,代码来源:Matrix.cpp

示例4: MatrixAdjoint

			Matrix Matrix::MatrixAdjoint()const {
				Matrix a;
				a.Element(0,0,(element[1][1]*element[2][2]-element[1][2]*element[2][1]));
				a.Element(0,1,-(element[1][0]*element[2][2]-element[1][2]*element[2][0]));
				a.Element(0,2,(element[1][0]*element[2][1]-element[1][1]*element[2][0]));

				a.Element(1,0,-(element[0][1]*element[2][2]-element[0][2]*element[2][1]));
				a.Element(1,1,(element[0][0]*element[2][2]-element[0][2]*element[2][0]));
				a.Element(1,2,-(element[0][0]*element[2][1]-element[0][1]*element[2][0]));

				a.Element(2,0,(element[0][1]*element[1][2]-element[0][2]*element[1][1]));
				a.Element(2,1,-(element[0][0]*element[1][2]-element[0][2]*element[1][0]));
				a.Element(2,2,(element[0][0]*element[1][1]-element[1][0]*element[0][1]));
				return a;
			}
开发者ID:francoisludewig,项目名称:MecaSolid,代码行数:15,代码来源:Matrix.cpp

示例5: RotationMatrix

// routine to extract the rotation part of the matrix
// assumes no entries in perspective section of matrix
Matrix Matrix::RotationMatrix()
{
	Matrix result = Identity();

	// copy first three elements of first three columns into result
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			result.Element(i,j) = Element(i,j);
	return result;
}
开发者ID:timothyandrew,项目名称:minigolf,代码行数:12,代码来源:Matrix.cpp

示例6: Element

// multiply by another matrix
Matrix Matrix::operator* (Matrix otherMatrix)
{
	// make a temporary copy of the other
	Matrix result;

	// now do the standard loops: it's inefficient, but works
	for (int row = 0; row < 4; row++)
	{
		for(int col = 0; col < 4; col++)
		{
			result.Element(row, col) = 0.0;
			for (int entry = 0; entry < 4; entry++)
			{
				result.Element(row, col) += Element(row, entry) *
					otherMatrix.Element(entry, col);
			}
		}
	}
	return result;
}
开发者ID:timothyandrew,项目名称:minigolf,代码行数:21,代码来源:Matrix.cpp

示例7: FormatContents

/// Re-arranges internal elements based on pre-configured or newly set options. Does not create or delete anything.
void UIMatrix::FormatContents()
{
	float labelHeightY = 0.0f;
//	if (label)
//		labelHeightY = label->sizeRatioY;
	float elementWidth = 1.0f / columns;
	float elementHeight = (1.0f - labelHeightY) / rows;

	Matrix<UIElement*> layoutMatrix; // Going downward in Y for each step.
	layoutMatrix.SetDefaultValue(NULL);
	layoutMatrix.SetSize(Vector2i(columns, rows));

	/// Create 'em.
	int formattedElements = 0;
	for (int y = 0; y < rows; ++y)
	{
		for (int x = 0; x < columns; ++x)
		{
			UIElement * element = matrixElements[formattedElements];
			layoutMatrix.Set(Vector2i(x, y), element);
			// Remove it first, if already there.
			RemoveChild(element);

			/// Give new alignments and size-ratios based on the matrix cell size.
			element->alignmentX = (x+0.5f) * elementWidth;
			element->alignmentY = 1.0f - (y + 0.5f) * elementHeight - labelHeightY;
			element->sizeRatioX = elementWidth;
			element->sizeRatioY = elementHeight;
			/// And add it!
			AddChild(element);
			// Make sure that the element is re-built next frame?
			++formattedElements;
			if (formattedElements >= matrixElements.Size())
				goto initialFormattingDone;
		}
	}
initialFormattingDone:
	/// After filling the matrix, set neighbour-elements accordingly.
	for (int i = 0; i < layoutMatrix.Elements(); ++i)
	{
		UIElement * element = layoutMatrix.Element(i);
		if (!element)
			continue;
		Vector2i matrixPos = layoutMatrix.GetLocationOf(element);
		/// Fetch right-left first.
		Vector2i leftPos = matrixPos + Vector2i(-1,0);
		if (layoutMatrix.ValidPosition(leftPos))
		{
			UIElement * left = layoutMatrix.GetItem(leftPos);
			if (left)
			{
				element->leftNeighbourName = left->name;
				left->rightNeighbourName = element->name;
			}
		}
		// Bottom-top neighbours
		Vector2i bottomPos = matrixPos + Vector2i(0, 1);
		if (layoutMatrix.ValidPosition(bottomPos))
		{
			UIElement * bottom = layoutMatrix.GetItem(bottomPos);
			if (bottom)
			{
				element->downNeighbourName = bottom->name;
				bottom->upNeighbourName = element->name;
			}
		}
	}

	;
}
开发者ID:erenik,项目名称:engine,代码行数:71,代码来源:UIMatrix.cpp


注:本文中的Matrix::Element方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。