本文整理汇总了C++中GLC_Matrix4x4::setMatRot方法的典型用法代码示例。如果您正苦于以下问题:C++ GLC_Matrix4x4::setMatRot方法的具体用法?C++ GLC_Matrix4x4::setMatRot怎么用?C++ GLC_Matrix4x4::setMatRot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLC_Matrix4x4
的用法示例。
在下文中一共展示了GLC_Matrix4x4::setMatRot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// Set Arcs orientation and position in concordance with mouse position
void GLC_RepTrackBallMover::init()
{
Q_ASSERT(NULL != m_pRepMoverInfo);
Q_ASSERT(!m_pRepMoverInfo->m_VectorInfo.isEmpty());
Q_ASSERT(!m_pRepMoverInfo->m_MatrixInfo.isEmpty());
GLC_Vector3d VectAngle(m_pRepMoverInfo->m_VectorInfo.first());
VectAngle.setZ(0);
VectAngle.setLength(1);
GLC_Matrix4x4 MatRot;
double Angle;
// Compute the 2 arcs orientation
if (VectAngle.y() > 0)
{ // Angle entre 0 et PI
Angle= acos(VectAngle.x());
MatRot.setMatRot(Z_AXIS, Angle);
}
else
{ // Angle between 0 et -PI
Angle= -acos(VectAngle.x());
MatRot.setMatRot(Z_AXIS, Angle);
}
// Composition of orientation matrix and mapping matrix
MatRot= m_pRepMoverInfo->m_MatrixInfo.first() * MatRot;
m_Arc1.setMatrix(MatRot * m_MatArc1);
m_Arc2.setMatrix(MatRot * m_MatArc2);
}
示例2: polygonPlaneNormal
QList<GLC_Point2d> glc::polygonIn2d(QList<GLC_Point3d> polygon3d)
{
const int count= polygon3d.count();
Q_ASSERT(count > 2);
// Compute face normal
const GLC_Point3d point1(polygon3d[0]);
const GLC_Point3d point2(polygon3d[1]);
const GLC_Point3d point3(polygon3d[2]);
const GLC_Vector3d edge1(point2 - point1);
const GLC_Vector3d edge2(point3 - point2);
GLC_Vector3d polygonPlaneNormal(edge1 ^ edge2);
polygonPlaneNormal.normalize();
// Create the transformation matrix
GLC_Matrix4x4 transformation;
GLC_Vector3d rotationAxis(polygonPlaneNormal ^ Z_AXIS);
if (!rotationAxis.isNull())
{
const double angle= acos(polygonPlaneNormal * Z_AXIS);
transformation.setMatRot(rotationAxis, angle);
}
QList<GLC_Point2d> subject;
// Transform polygon vertexs
for (int i=0; i < count; ++i)
{
polygon3d[i]= transformation * polygon3d[i];
// Create 2d vector
subject << polygon3d[i].toVector2d(Z_AXIS);
}
return subject;
}
示例3: triangulatePolygon
// Triangulate a no convex polygon
void glc::triangulatePolygon(QList<GLuint>* pIndexList, const QList<float>& bulkList)
{
int size= pIndexList->size();
if (polygonIsConvex(pIndexList, bulkList))
{
QList<GLuint> indexList(*pIndexList);
pIndexList->clear();
for (int i= 0; i < size - 2; ++i)
{
pIndexList->append(indexList.at(0));
pIndexList->append(indexList.at(i + 1));
pIndexList->append(indexList.at(i + 2));
}
}
else
{
// Get the polygon vertice
QList<GLC_Point3d> originPoints;
QHash<int, int> indexMap;
QList<int> face;
GLC_Point3d currentPoint;
int delta= 0;
for (int i= 0; i < size; ++i)
{
const int currentIndex= pIndexList->at(i);
currentPoint= GLC_Point3d(bulkList.at(currentIndex * 3), bulkList.at(currentIndex * 3 + 1), bulkList.at(currentIndex * 3 + 2));
if (!originPoints.contains(currentPoint))
{
originPoints.append(GLC_Point3d(bulkList.at(currentIndex * 3), bulkList.at(currentIndex * 3 + 1), bulkList.at(currentIndex * 3 + 2)));
indexMap.insert(i - delta, currentIndex);
face.append(i - delta);
}
else
{
qDebug() << "Multi points";
++delta;
}
}
// Values of PindexList must be reset
pIndexList->clear();
// Update size
size= size - delta;
// Check new size
if (size < 3) return;
//-------------- Change frame to mach polygon plane
// Compute face normal
const GLC_Point3d point1(originPoints[0]);
const GLC_Point3d point2(originPoints[1]);
const GLC_Point3d point3(originPoints[2]);
const GLC_Vector3d edge1(point2 - point1);
const GLC_Vector3d edge2(point3 - point2);
GLC_Vector3d polygonPlaneNormal(edge1 ^ edge2);
polygonPlaneNormal.normalize();
// Create the transformation matrix
GLC_Matrix4x4 transformation;
GLC_Vector3d rotationAxis(polygonPlaneNormal ^ Z_AXIS);
if (!rotationAxis.isNull())
{
const double angle= acos(polygonPlaneNormal * Z_AXIS);
transformation.setMatRot(rotationAxis, angle);
}
QList<GLC_Point2d> polygon;
// Transform polygon vertexs
for (int i=0; i < size; ++i)
{
originPoints[i]= transformation * originPoints[i];
// Create 2d vector
polygon << originPoints[i].toVector2d(Z_AXIS);
}
// Create the index
QList<int> index= face;
const bool faceIsCounterclockwise= isCounterclockwiseOrdered(polygon);
if(!faceIsCounterclockwise)
{
//qDebug() << "face Is Not Counterclockwise";
const int max= size / 2;
for (int i= 0; i < max; ++i)
{
polygon.swap(i, size - 1 -i);
int temp= face[i];
face[i]= face[size - 1 - i];
face[size - 1 - i]= temp;
}
}
QList<int> tList;
triangulate(polygon, index, tList);
size= tList.size();
//.........这里部分代码省略.........