Abstract This paper investigates the (semi)group action of $\textrm{SL}_{n}({\mathbb R})$ on ${\mathbb P}({\mathbb R}^{n})$, a primary example of non-conformal, non-linear, and non-strictly contracting action. We establish variational principles of the affinity exponent for two main examples: the Borel Anosov representations and the Rauzy gasket. In [ 32], they obtain a dimension formula for the stationary measures on ${\mathbb P}({\mathbb R}^{3})$. Combined with our result, it allows us to study the Hausdorff dimension of limit sets of Anosov representations in $\textrm{SL}_{3}({\mathbb R})$ and the Rauzy gasket. It yields the equality between the Hausdorff dimensions and the affinity exponents in both settings, generalizing the classical Patterson–Sullivan formula. In the appendix, we improve the numerical lower bound of the Hausdorff dimension of Rauzy gasket to $1.5$.