本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
;
}