{'fraction_non_alphanumeric': 0.04094700975208554, 'fraction_numerical': 0.02103160615673834, 'mean_word_length': 4.801976823449216, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A General Homogeneous Matrix Formulation to 3D Rotation Geometric Transformations

We present algebraic projective geometry definitions of 3D rotations so as to bridge a small gap between the applications and the definitions of 3D rotations in homogeneous matrix form. A general homogeneous matrix formulation to 3D rotation geometric transformations is proposed which suits for the cases when the rotation axis is unnecessarily through the coordinate system origin given their rotation axes and rotation angles.


Introduction
Geometric transformation rotation is a basic and fundamental concept which has applications in computer graphics, vision and robotics and has been investigated and depicted thoroughly in many classic literatures [3,[6][7][8][11][12][13] . Rotations of practical importance are those 2D and 3D rotation transformations represented by quaternion and vectors in Euclidean space, and by homogeneous matrices in projective spaces.
It is well known quaternion is a useful tool in representing 3D rotations [8,[11][12][13] which, however, has the difficulty of representing general 3D rotations with rotation axes not passing through the coordinate system origin. An alternative Rodrigues formula which explicitly contains the point vector to be transformed can be used to solve this problem [3, p.165] . Such an approach only solves the formulation problem of 3D rotation definition while leaves the geometric meaning definition of its algebraic formulation unarticulated.
Since all 3D rotations thus represented are actually dependent on their Euclidean geometric meaning and therefore are not in homogeneous matrices, which sometimes are of special use in applications, e.g., in homogeneous representation, compound geometric transformations can be simply represented as concatenated production of the corresponding homogeneous matrices in sequence especially when some of the geometric transformations, e.g., perspective projections and translations, have only homogeneous matrix forms.
To the best of our knowledge, there is no homogeneous matrix formula or definition to general 3D rotations yet in projective space. In order to represent such 3D rotation formula in general cases, 3D rotations first have to be well-defined in projective space. The difficulty of algebraically defining homogeneous geometric transformations in projective space is readily to be underestimated because of the native Euclidean geometric intuitions of such geometric transformations in one's mind.
First, since using homogeneous coordinates means pure algebraic representation in projective space, it is reasonable to expect that a nice definition to some specific geometric transformation is not only compatible with the conventional Euclidean intuitions but also independent of its Euclidean geometric background, i.e., such fundamental Euclidean concepts as distances would be invalid, angles have to be represented via cross ratio via Laguerre's formula [7, pp.342,409] , and Euclidean transformations dependent on the validity of distance become undefined. Second, by saying well-defined or nice we mean a definition is able to solve the following two sides of a geometric transformation definition problem: on the one side, given a homogeneous matrix, uniquely identify its geometric classification and characteristic features; on the other side, given sufficient characteristic geometric features, uniquely determine the homogeneous matrix of a geometric transformation.
Considering the homogeneous matrix in (1), without such non-projective-geometry concepts as distance, perpendicularity and so on, classic definitions of rotation have logic difficulties in identifying it as a rotation and determine the rotation axis and angle in projective space.  Additionally, in order to obtain reference frame independent matrix of a 3D rotation, the conventional representation highly depends on the following unarticulated truth, which holds for any geometric transformation T 0 in square matrices(Note: column vector convention used unless otherwise specified): Theorem 1. Suppose T 0 is a geometric transformation in projective space which transforms an arbitrary point X into Y ; and the homogeneous coordinates of X and Y in reference coordinate systems (I) and (II) are (x), (y), (x ′ ), (y ′ ) respectively; the transformation matrices of T 0 in (I) and (II) are A and B respectively, i.e., (y) = A(x), (y ′ ) = B(x ′ ); suppose the coordinate transformation from (I) to (II) is a nonsingular square matrix T , i.e., (x ′ ) = T (x), (y ′ ) = T (y); then: The matrices of T 0 in (I) and (II) are similar.
Though theorem 1 indicates that the characteristic algebraic features of a homogeneous geometric transformation are its eigenvalues and their algebraic and geometric multiplicities, none of the conventional definitions of geometric transformations has taken advantage of such rules to reveal the inherent connection between the geometric meaning of homogeneous matrices and their eigenvalues.
Take rotation with θ angle and axis passing through P : (2, 1, 5, 1) and Q : (4, 7, 2, 1) as an example [6, p.47] . Note that we use row vector convention only in this example such that the results here without transposing are consistent with those in [6, p.47] . Conventional method tries to construct a series of Euclidean geometric transformations E i (i = 1, 2, · · · , n) such that the final rotation R obtained in (3) per equation (2) is similar to a known rotation R 0 in (2) in the standard Givens rotation form around coordinate axis z: Such an approach in determining the homogeneous matrix of a general rotation has the following drawbacks: (i) The definition of a general rotation in homogeneous representation and projective space is algebraically dependent on the standard Givens rotations inherited from Euclidean spaces; (ii) A series of Euclidean transformations E i , the homogeneous matrices of which are actually algebraically undefined in projective geometry, have to be employed which can be chosen almost arbitrarily, which makes the procedure flawed and a little more complicate to program and code; (iii) There is no algebraic definition in projective space to determine the geometric meaning of homogeneous matrix in equation (3) conversely without using such non-projective-geometry concepts as distance.
By using an extended Desargues theorem [10, pp.75~76] and examining the thus obtained extended Desarguesian configuration [1,2] via an algebraic projective geometric approach, Householder's elementary matrices [5, pp.1~3] were rewritten into new forms as in table 1 and defined as stereohomology which consists of most of the basic geometric transformations with such nice definitions in projective space.
In this work, we will extend such work to rotations which are not any more elementary to solve the definition issue for 3D rotations in projective space. A general homogeneous matrix formula to 3D rotations will also be presented. We first define rotations in 2D and 3D projective spaces, and then present two approaches to obtain homogeneous matrix formula of general 3D rotations, i.e., the rotation axes of them do not have to pass through the coordinate system origin.

Definition of 2D and 3D rotations
Note that column homogeneous vectors, instead of row vectors, will be employed as default point and geometric transformation representation convention hereafter in this paper, which is different from the convention adopted by [6, p.47] .
The uncertainty of representing an arbitrary 3D rotation in homogeneous matrix form mainly lies in the 3D rotation axis representation. Though lines in 3-space can be represented in their Plüker coordinates [4, pp.68~72] [7, pp.216~218] , which brings convenience in representing intersection or joining of lines with 3D points and hyperplanes, it is difficult to use the coordinates information directly into geometric transformation representation.
Though quaternions can elegantly express rotations with arbitrary axis passing through the origin in three dimensions [8, pp.50~54] [12, pp.177~180] , [13, pp.92~95] , for rotation axes which are in general not passing through the origin, we may have to use a pair of translations which are inverse to each other so that to obtain the desired rotation per theorem 1.
A rotation can be defined as the compound operation or the product of two reflections according to [7, pp.419~422] , but there is no simple rotation representation derived based on such definitions yet. In this section we shall both use the compound transformation of two orthographic reflections defined as involutory stereohomology in table 1 and use the eigen-system of the rotation which is inherent algebraic features per theorem 1, to represent a general rotation.
The definition of an orthographic reflection in [2] takes advantage of the existence and uniqueness of an involutory projective transformation which transforms X i and S in the extended Desargues configuration figure 1) into Y i and S in sequence respectively. The homogeneous square matrix formulation of such a reflection was proved to be in the form as indicated in table 1 [2] .

Figure 1: Extended Desarguesian configuration for reflection
Note that in order to make the definitions in algebraic projective geometry compatible with the Euclidean geometry intuitions in one's mind, we have to make choices to distinguish ordinary and infinite geometric elements which are algebraically indistinguishable in projective space. Then we redefine homogeneous rotations in P n ( only when n = 2,3) in this paper as: Definition 1 (Rotation). A rotation in P n is a compound transformation of two orthographic reflections of which the stereohomology centers S 1 and S 2 are different infinite points, and sterehomology hyperplanes π 1 and π 2 are ordinary elements(see table 1 for definitions of elementary geometric transformations).
The rotation angle θ of the rotation is twice that of dihedral angle ω between π 1 and π 2 which can be represented by Laguerre's formula by involving cross ratio [7, pp.342,409] .
The above definition 1 is directly borrowed from the classic definitions in projective geometry, and is theoretically dependent on the possibility of defining normal reflection as an involutory stereohomology in table 1, detailed illusta-tion of which can be seen in [1,2] (in Chinese) where modified Householder's elementary matrices [5, 1~3] are presented and defined into stereohomology as in table 1 based on an extension to Desargues theorem [10, 75~76] . Otherwise, we have not find any other opportunity of define rotation via such an approach in algebraic projective geometry. It is only based on definition 1 that we can obtain a pure algebraic definition 2 of 2D and 3D rotations in projective space without using any non-projective-geometry concept, i.e., it is logically inappropriate to immediately adopt a Givens matrix as a standard rotation. Definition 2 (Rotation). A rotation in P n (n = 2,3) with rotation angle θ and rotation axis l (the latter of which should be able to be represented as the intersection of two hyperplanes in P n ) is a projective transformation of which: (1) the ratios of all eigenvalues are cosθ ± i· sinθ and 1; (2) points on rotation axis l are the associated eigenvectors with the ratio 1 real eigenvalue, and (3) the associated eigenvectors with eigenvalues of ratios cosθ ± i· sinθ are the intersetion points of the imaginary conics [9, p.204] and the infinite hyperplane in P 2 , or are the intersection points of the imaginary quadrics [9, p.204] , the infinite hyperplane, and any ordinary hyperplane of which the normal direction is the direction of the rotation axis when it is in P 3 .
We shall obtain homogeneous rotations based on definitions 1 and 2 via two approaches different from those in [6, pp.33~34,43~48] , [8, pp.43~52] , [11, p.36] , [12, pp.89~90,115~118,177~180] : (I) find two hyperplanes of which their intersection line being rotation axis and the dihedral angle ω being half the angle θ, then the products of reflections about the two hyperplanes will be desired rotation and its inverse (per definition 1), further characteristic geometric features of positive direction of rotation axes and the right-or left-handed rule, can finalize the desired rotation; (II) find all the eigenvalues and their associate eigenvectors, then the rotation and its inverse can be obtained by reconstructing from its eigen-decomposition factors(per definition 2), further characteristic geometric information on the rotation similar to above uniquely determines the rotation.

Formulation to general 3D rotations
The formulation problem of 2D rotations has actually been well resolved [6,8,[11][12][13] even without considering the new definitions 1 and 2 here. Now let's go on with the 3D homogeneous rotations. The major difference from 2D cases is that the 3D rotation axis can be represented as either intersection of two hyperplanes or a line joining two points. For the latter, there are two possibilities: (1) both points are ordinary; (2) one point is infinite and represents direction of the axis. When rotation axis is determined by two hyperplanes, we use the first approach by definition 1. The key is to find a pair of hyperplanes, the intersection line of which is the rotation axis, and the dihedral angle of which is half the rotation angle θ.
If the rotation axis is given by the intersection of two hyperplanes π 1 and π 2 [9, pp.58~69] : Suppose the dihedral angle between π 1 and π 2 is ω, then hyperplane equations which intersect π 1 and π 2 at the rotation axis and have ±θ/2 dihedral angles with π 1 are: By using either of the two hyperplane equations in equation (5) and that of π 1 , two reflections can easily be obtained, the product of which are the desired 3D homogeneous rotation and its inverse. Generally equation (5) is more suitable for numerical rotation matrix estimation since the two hyperplanes can be arbitrary and the rotation matrix thus obtained is not unique and therefore the analytical form of the rotation matrix will not be given here.
Next let us consider the rotation axis determined by two points. Since when both the two points are ordinary, the direction (per definition of direction as stereohomology in table 1) of one point from another will be the direction of the axis, we only discuss the case when one is an ordinary point while another is infinite, i.e., a direction. Denote the ordinary point as (x 0 , y 0 , z 0 , 1) T and the direction (a, b, c, 0) T (without loss of generality, let a 2 + b 2 + c 2 = 1).
If the representation of axis by two points can be converted into by two hyperplanes similar to that in equation (4) then we can use the similar approach by equations (4) and (5) to obtain the rotation. The pencil of hyperplanes through the line joining (x 0 , y 0 , z 0 , 1) T and (a, b, c, 0) T should satisfy: where (α, β, γ, 0) T is the normal direction of the hyperplane pencil passing through the two points.
Without loss of generality, let c = 0, substitute γ = −(α · a + β · b)/c into equation (6) we have: which can be re-written into: By obtaining equation (7), we have successfully represented the rotation axis determined by two points into the a pencil of hyperplanes passing through the axis [9, pp.58~69] . Then use the first approach as used by equations (4) and (5) we can obtain the 3D homogeneous rotation. Now let's try the second approach when rotation axis is determined by (x 0 , y 0 , z 0 , 1) T and (a, b, c, 0) T . Clearly both (x 0 , y 0 , z 0 , 1) T and (a, b, c, 0) T are eigenvectors associated with eigenvalue 1. As eigenvectors, imaginary and infinite points (x 1 , x 2 , x 3 , x 4 ) T satisfy: Without loss of generality, let the two conjugated eigenvectors are: (α + i · β, λ + i · ρ, 1, 0) T and (α − i · β, λ − i · ρ, 1, 0) T , which satisfy equations in (8), and therefore are rewritten as in equations (9) on the left and can be solved as those in equations (9) on the right: Equations: Solution: The right-handed 3D homogeneous rotation by the four eigenvalues and their associated eigenvectors is given as in (10), which for application convenience has been rewritten into a user friendly form similar to the classic Rodrigues' formula [3, p.165] (Note: without loss of generality, we assumed a 2 + b 2 + c 2 = 1): R 3D (x 0 , y 0 , z 0 , a, b, c, θ) = C 1 + (sin θ · A 2 − (1 − cos θ) · O 3 ) · T 4 where:

Translation
And now it is easy to identify the homogeneous matrix in (1) per definition 2 as a rotation by solving its eigensystem via eigen-decomposition: the rotation axis has a direction of (−5, 3, 1, 0) T (choice of positive direction) while passing through fixed points as (−4 − 5t, 4 + 3t, t, 1) T (∀t ∈ R) and the rotation angle is 2kπ + π 6 (choice of right-handed rule), the homogeneous matrix of which can be conversely obtained via equation (10) by normalizing the axis direction and set t as any convenient specific real value, e.g., 0.