本文整理汇总了C++中Matrix2D::Transform方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix2D::Transform方法的具体用法?C++ Matrix2D::Transform怎么用?C++ Matrix2D::Transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix2D
的用法示例。
在下文中一共展示了Matrix2D::Transform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Collides
bool Line::
Collides( const Line &other, const Placement &thisPlacement,
const Placement &otherPlacement ) const {
Matrix2D thisTransform = thisPlacement.Get2DMatrix();
Matrix2D otherTransform = otherPlacement.Get2DMatrix();
Vec2D thisStart = thisTransform.Transform( start - thisPlacement.GetRotationPivot() );
Vec2D thisEnd = thisTransform.Transform( end - thisPlacement.GetRotationPivot() );
Vec2D otherStart = otherTransform.Transform( other.start - otherPlacement.GetRotationPivot() );
Vec2D otherEnd = otherTransform.Transform( other.end - otherPlacement.GetRotationPivot() );
return Collides( thisStart, thisEnd, other.origin, otherStart, otherEnd );
}
示例2: Collision
ol::Collision ol::Shape::
LineStripCollision( const std_container1 &vertices, const std_container2 &otherVertices,
const Placement &thisPlacement, const Placement &otherPlacement,
bool getResults, bool thisConnectFirstAndLast, bool otherConnectFirstAndLast ) const {
if( vertices.size() < 2 || otherVertices.size() < 2 ) {
OlError( "An empty shape can't ever collide!" );
return Collision( false );
}
Vec2D thisCo = thisPlacement.GetPosition();
Vec2D otherCo = otherPlacement.GetPosition();
Matrix2D thisTransform = thisPlacement.Get2DMatrix();
Matrix2D otherTransform = otherPlacement.Get2DMatrix();
typename std_container1::const_iterator thisIter = vertices.begin();
const Vec2D rotationPivot = thisPlacement.GetRotationPivot();
const Vec2D otherRotationPivot = otherPlacement.GetRotationPivot();
Vec2D thisPrev = thisTransform.Transform( *thisIter - rotationPivot ) + thisCo + rotationPivot;
thisIter++;
std::vector< LinePair * > segmentLists;
// Loop through each vertex //
while( true ) {
bool breakNow = false;
// Test if we've reached the last line segment //
if( thisIter == vertices.end() ) {
if( !thisConnectFirstAndLast ) {
break;
}
breakNow = true;
thisIter = vertices.begin();
}
Vec2D thisVertex = thisTransform.Transform( *thisIter - rotationPivot ) + thisCo + rotationPivot;
thisIter++;
typename std_container2::const_iterator otherIter = otherVertices.begin();
Vec2D otherPrev = otherTransform.Transform( *otherIter - otherRotationPivot ) + otherCo + otherRotationPivot;
otherIter++;
// Loop through each vertex of the other polygon //
while( true ) {
bool breakNow = false;
// Test if we've reached the last line segment of the other polygon //
if( otherIter == otherVertices.end() ) {
if( !otherConnectFirstAndLast ) {
break;
}
breakNow = true;
otherIter = otherVertices.begin();
}
Vec2D otherVertex = otherTransform.Transform( *otherIter - otherRotationPivot )
+ otherCo + otherRotationPivot;
otherIter++;
// Test for collision //
if( IsCounterClockwise( thisPrev, thisVertex, otherPrev )
!= IsCounterClockwise( thisPrev, thisVertex, otherVertex )
&&
IsCounterClockwise( otherPrev, otherVertex, thisPrev )
!= IsCounterClockwise( otherPrev, otherVertex, thisVertex )) {
if( !getResults ) {
return Collision( true );
}
else {
Line thisLine( thisVertex, thisPrev );
Line otherLine( otherVertex, otherPrev );
segmentLists.push_back( new LinePair( thisLine, otherLine ));
/*
return Collision( thisLine, otherLine );*/
}
}
// Is last line segment of the other polygon processed? //
if( breakNow ) {
break;
}
// Advance to the next vertex of the other polygon //
otherPrev = otherVertex;
}
// Is last line segment processed? //
if( breakNow ) {
break;
}
//.........这里部分代码省略.........