Background::Background() : Sprite(Texture::ID::Background) , mCenter(GetTextureInfos()->infos.Width / 2, GetTextureInfos()->infos.Height / 2, 0) { SetPivot(mCenter); SetRotationRad(0, 0, D3DX_PI); }
Bumper::Bumper() : AllBumpers(Texture::ID::Bumper) , mCenter(GetTextureInfos()->infos.Width / 2, GetTextureInfos()->infos.Height / 2, 0) , mPos(GetTextureInfos()->infos.Width / 2, GetTextureInfos()->infos.Height / 2, 0) { SetPivot(mCenter); this->SetID(Components::Bumper); }
Text::Text(Texture::ID id, D3DXVECTOR2 pos, bool visibility) : Sprite(id) , mCenter(GetTextureInfos()->infos.Width / 2, GetTextureInfos()->infos.Height / 2, 0.f ) { SetPivot(mCenter); SetRotationRad(D3DX_PI, 0.f, D3DX_PI); SetVisible(visibility); SetPosition(pos.x + mCenter.x, pos.y - mCenter.y); }
PigPeg::PigPeg() : Sprite(Texture::PIGPEG) { //Setting ID, initial position, pivot, collider and rotate it so the sprite is not upside down. this->SetID(Components::PigPeg); float radius = 8; collider = new CCircle(this, 0, 0, radius); SetPivot(D3DXVECTOR3(GetTextureInfos()->infos.Width / 2, GetTextureInfos()->infos.Height / 2, 0)); SetRotationDeg(0, 0, 180.f); }
Basket::Basket() :Sprite(Texture::BASKET) , posX(0.0f) , posY(-230.0f) , speed(100.0f) , center(GetTextureInfos()->infos.Width / 2, GetTextureInfos()->infos.Height / 2, 0.0f) , dir(1.0f) { // Place in world SetPosition(posX, posY); SetPivot(¢er); SetRotation(0.0f, 0.0f, 180*(D3DX_PI / 180)); }
Canon::Canon() : Sprite(Texture::ID::Canon) , mCenter(GetTextureInfos()->infos.Width / 2, GetTextureInfos()->infos.Height / 2, 0) , shotRot(0) , canonRot(D3DX_PI / 2) , ROTATION_SPEED(0.1) , isShot(false) , waitTime(0.f) , isGainLife(false) , waitGainLife(0.f) , shotDirection(0.f, 0.f, 0.f) , nbBalls(3) { SetPivot(mCenter); SetRotationRad(0.f, 0.f, canonRot); SetPosition(0, gApp->GetParam().BackBufferHeight / 2); hudLives = new HUDLives(); hudLives->UpdateLives(nbBalls); }
/* * Gaussian elimination is an algorithm that can be used to determine the solutions of a * system of linear equations, to find the rank of a matrix, and to calculate the inverse * of an invertible square matrix. Gaussian elimination is named after German * mathematician and scientist Carl Friedrich Gauss. * * Elementary row operations are used throughout the algorithm. The algorithm has two * parts, each of which considers the rows of the matrix in order. The first part reduces * the matrix to row echelon form while the second reduces the matrix further to reduced * row echelon form. The first part alone is sufficient for many applications. */ void Regress::DoPolynomial( unsigned int _degree ) { degree = ( _degree > POLYNOMIAL_DEGREE ) ? POLYNOMIAL_DEGREE : _degree; SetMatrix(); // construct the regression matrix double ratio; unsigned int u; for ( unsigned int s = 0; s < factor.size(); ++s ) { if ( !SetPivot( s ) ) { throw SireMaths::math_error( QObject::tr( "Cannot fit the polynomial as the matrix is singular."), CODELOC ); // cout << "Error: matrix is singular" << endl; // exit( 1 ); } // apply partial pivoting to the matrix and check for singularity for ( unsigned int i = ( s + 1 ); i < factor.size(); ++i ) { ratio = matrix[ Translate( i, s ) ] / matrix[ Translate( s, s ) ]; factor[ i ] -= factor[ s ] * ratio; for ( unsigned int j = s; j < factor.size(); ++j ) { matrix[ Translate( i, j ) ] -= ( matrix[ Translate( s, j ) ] * ratio ); } // successively remove previous terms } // perform forward elimination on the matrix } // perform gauss elimination with partial pivoting for ( unsigned int offset = 0; offset < factor.size(); ++offset ) { u = factor.size() - offset - 1; ratio = factor[ u ] / matrix[ Translate( u, u ) ]; matrix[ Translate( u, u ) ] = 1.0; factor[ u ] = ratio; for ( unsigned int v = 0; v < u; ++v ) { factor[ v ] -= ( matrix[ Translate( v, u ) ] * ratio ); matrix[ Translate( v, u ) ] = 0.0; } // update the solution to the linear equations } // perform backward substitution } // end of DoPolynomial()
void Transform2D::SetPivotY(const float y) { SetPivot(m_pivot.x, y); }
void Transform2D::SetPivotX(const float x) { SetPivot(x, m_pivot.y); }
void Transform2D::SetPivot(const float x, const float y) { SetPivot(vec2(x, y)); }
void UUnrealEdEngine::UpdatePivotLocationForSelection( bool bOnChange ) { // Pick a new common pivot, or not. AActor* SingleActor = nullptr; USceneComponent* SingleComponent = nullptr; if (GetSelectedComponentCount() > 0) { for (FSelectedEditableComponentIterator It(*GetSelectedComponents()); It; ++It) { UActorComponent* Component = CastChecked<UActorComponent>(*It); AActor* ComponentOwner = Component->GetOwner(); if (ComponentOwner != nullptr) { auto SelectedActors = GetSelectedActors(); const bool bIsOwnerSelected = SelectedActors->IsSelected(ComponentOwner); check(bIsOwnerSelected); if (ComponentOwner->GetWorld() == GWorld) { SingleActor = ComponentOwner; if (Component->IsA<USceneComponent>()) { SingleComponent = CastChecked<USceneComponent>(Component); } const bool IsTemplate = ComponentOwner->IsTemplate(); const bool LevelLocked = !FLevelUtils::IsLevelLocked(ComponentOwner->GetLevel()); check(IsTemplate || LevelLocked); } } } } else { for (FSelectionIterator It(GetSelectedActorIterator()); It; ++It) { AActor* Actor = static_cast<AActor*>(*It); checkSlow(Actor->IsA(AActor::StaticClass())); if (Actor->GetWorld() == GWorld) { const bool IsTemplate = Actor->IsTemplate(); const bool LevelLocked = !FLevelUtils::IsLevelLocked(Actor->GetLevel()); check(IsTemplate || LevelLocked); SingleActor = Actor; } } } if (SingleComponent != NULL) { SetPivot(SingleComponent->GetComponentLocation(), false, true); } else if( SingleActor != NULL ) { // For geometry mode use current pivot location as it's set to selected face, not actor FEditorModeTools& Tools = GLevelEditorModeTools(); if( Tools.IsModeActive(FBuiltinEditorModes::EM_Geometry) == false || bOnChange == true ) { // Set pivot point to the actor's location FVector PivotPoint = SingleActor->GetActorLocation(); // If grouping is active, see if this actor is part of a locked group and use that pivot instead if(GEditor->bGroupingActive) { AGroupActor* ActorGroupRoot = AGroupActor::GetRootForActor(SingleActor, true, true); if(ActorGroupRoot) { PivotPoint = ActorGroupRoot->GetActorLocation(); } } SetPivot( PivotPoint, false, true ); } } else { ResetPivot(); } }