To come in
Speech therapy portal
  • How to gain self-confidence, achieve calmness and increase self-esteem: discovering the main secrets of Gaining self-confidence
  • Psychological characteristics of children with general speech underdevelopment: features of cognitive activity Mental characteristics of children with onr
  • What is burnout at work and how to deal with it How to deal with burnout at work
  • How to Deal with Emotional Burnout Methods for Dealing with Emotional Burnout
  • How to Deal with Emotional Burnout Methods for Dealing with Emotional Burnout
  • Burnout - How To Deal With Work Stress How To Deal With Emotional Burnout
  • Affine transformations using homogeneous coordinates. Coordinate Space Transformations Affine Coordinate Transformations

    Affine transformations using homogeneous coordinates.  Coordinate Space Transformations Affine Coordinate Transformations

    First, let's define what are transformations? Let's say we have a model (let's say it is a triangle for simplicity). And three coordinate spaces: object (in which this triangle is described), world and camera space. So, a transformation is an expression of the coordinates of an object located in one coordinate system (object) using the coordinates of another coordinate system (first the world one, and then the camera one).

    As I wrote earlier, using different coordinate spaces makes it easier to create a virtual world. Objects are created in object space, and each object has its own coordinate space. World space connects all objects of the virtual world and allows you to do very difficult things - very simple (for example, moving objects). After the scene is created and all objects are moved, the world coordinates are transformed into the coordinate space of the camera. We will only use one camera, but in real situations, you can create several. Several cameras, for example, were used in the ingenious game Earth 2150: Escape from the blue planet.

    So what I'm talking about: transformations are needed to use multiple coordinate spaces.

    First, let's remember a few things about vectors. The following figure will help us with this:

    What we see here: the world coordinate space formed by the x, y, z axes. Unit vectors i, j, k are called orts or basis vectors of the world coordinate space. Using the sum of these vectors, you can get any vector in the world coordinate space.

    v is a vector that connects the world origin and the object origin. The length of the vector v is equal to the distance between the world origin and the object origin. Consider the vector form v=(5,2,5):

    v= x * i+ y * j+ z * k = 5*i + 2*j + 5*k

    As I already wrote above, with the help of basis vectors it is possible to represent any point (vector) of a given space, which is demonstrated by this equation.

    Vectors p,q,r- basis vectors of object space. Note that i,j,k will not necessarily be equal p,q,r.

    In this illustration, I have omitted a number of details: in the object coordinate space, three points are defined that form a triangle. In addition, I have not indicated the camera, which is directed towards the triangle.

    Linear coordinate transformations using matrices

    First, let's look at the unit vectors i,j,k, which coincide in direction with the coordinate axes of world space and are called orts or base vectors of world space.

    Let's write these vectors in coordinate form in the form of matrices:

    i= [i x i y i z] = [1 0 0] j= [j x j y j z] = [0 1 0] k= [k x k y k z] = [0 0 0]

    Here vectors are represented by 1x3 matrices (row matrices).

    We can write these basis vectors using one matrix:

    And even more importantly, we can write these vectors like this:

    As you can see, we got a 3x3 or 4x4 identity matrix.

    It would seem, what's wrong with that? Just think, there is an opportunity to write some stupid basis vectors of space in one matrix. But no, you won't "think" !!! This is where one of the darkest secrets of 3D programming lies.

    As I wrote above, any point that is present in the virtual world can be written in vector form:

    v= x * i+ y * j+ z * k

    Where v- point in space, x, y, z - point coordinates v, a i,j,k- basis vectors of space. Note that we are talking about a point here, but we are considering a vector. I hope you remember that a vector and a point are essentially the same thing.

    The formula above is called the vector form of the vector. There is another name - a linear combination of vectors. This is true, by the way.

    Now let's take another look at the vector v... Let's write it in the row matrix: v = [ 5 2 5 ]

    Note that the length of the vector v is the distance from the origin of world coordinate space to the origin of object coordinate space.

    Let's try to multiply this vector by a matrix in which the basis vectors of world space are written (I hope you remember the matrix multiplication formula):

    As a result, we get the following equation:

    v M = [(xi x + yj x + zk x) (xi y + yj y + zk y) (xi z + yj z + zk z)]

    We got a vector. Those. the result of multiplying a vector by a matrix is ​​a vector. In this case, the vector has not changed. But if the elements of the matrix are not ones (on the main diagonal) and zeros (all other elements), but some other numbers, then the vector will change. Therefore, we can say that the matrix M performs a coordinate space transformation. Consider the general formula:

    a, b - vectors, M - transformation matrix of coordinate spaces. The formula can be read like this: "matrix M transforms point a to point b".

    Let's look at an example for clarity. We need to convert coordinates from object space (p, q) to world (i, j):

    i,j- basic vectors of the world space, p,q- basis vectors of object space. In the picture, you can see that the object coordinate space is rotated by -45 degrees around the z-axis (it is not visible in the picture). Moreover, vectors q,p 1.5 times more vectors i,j, which means that objects defined in object space will look one and a half times smaller in world space.

    To visualize how the object space model will look after transformation, you can add a frame for vectors i,j:

    You can draw the same frame for p,q, but I didn't clutter up the drawing.

    Now, let's say we have a triangle drawn in object space (Fig. A). In world space, this triangle will be rotated 45 degrees and reduced by one third (Fig. B):

    Now let's collect all the elements of the mosaic: as we know, the transformation can be done using a matrix. Basis vectors are matrix rows. The coordinates of the base vectors of the world coordinate space in object space are as follows:

    i = [ 0.473 0.473 ] j = [ -0.473 0.473 ]

    How did we know the coordinates? First, we know that the coordinate spaces are rotated 45 degrees relative to each other. Second, the base vectors of object space are 1.5 times longer than the base vectors of world space. Knowing this, we easily calculated the coordinates of the vectors i,j.

    As a result, we get the following transformation matrix (in this case, rotation or rotation):

    Or in three-dimensional space:

    All figures are approximate.

    This is a matrix of transformation of coordinates from object space to inertial space (I remind you that the basis vectors of the inertial space coincide with the basis vectors of the world space). To transform a triangle from object space to inertial space, you need to multiply all points (vectors) of the triangle by the transformation matrix.

    In the last example, we encountered two transformations: rotation and scaling. Both of these transformations are linear.

    Now that we have looked at examples of linear transformations, you can get acquainted with the definition:

    Linear transformations are coordinate transformations that do not distort spaces. Those. all parallel lines remain parallel (there is, however, one exception). Or quite simply: with linear transformations, a triangle will never turn into a circle or a square, but will always remain a triangle.

    Now that we roughly understand what linear transformations are, consider specific formulas:

    Scale

    k 1, k 2, k 3 - scaling factors. If k is 1, there is an increase in objects.

    Rotation or rotation

    Rotation around the x-axis:

    Rotation around the y-axis:

    Rotation around the z-axis:

    By the way, we used this matrix (rotation around the z-axis) above.

    Rotation can be not only around the axes forming the coordinate space, but also around arbitrary straight lines. The formula for turning around an arbitrary straight line is rather complicated, we are not yet ready to consider it.

    The most important thing to remember from the above is the following: the rows of the transformation matrix contain the basis vectors of the new coordinate space, expressed in terms of the coordinates of the old coordinate space. ...

    If you understand this simple thing (that the basis vectors of the new space are written in the matrix), then looking at the transformation matrix, you can easily see the new coordinate space.

    And the last one:
    Linear transformations cannot move objects. Those. objects can be enlarged / reduced, they can be rotated, but they remain stationary.

    Affine transformations

    Affine transformations are linear transformations with carry. With the help of affine transformations, you can move objects.

    The formula is very simple:

    A = bM + v;

    Where b is the origin, M is the linear transformation matrix, a is the transformed point, and v is the vector connecting the two spaces. Or in other words, it is a vector whose length is equal to the distance between two coordinate spaces.

    In the picture at the beginning of the lesson, it is the affine transformation that is needed: first, a linear transformation from object space to inertial space, and then transferring all points of object space to world space using the vector v.

    To simplify calculations in 3D graphics programming, four-dimensional vectors, 4x4 matrices and so-called homogeneous coordinates are used. The fourth dimension does not play any role, it is introduced only to simplify calculations.

    In a 4D vector, you guessed it, there are four components: x, y, z, and w. The fourth component of the vector is called the homogeneous coordinate.

    It is very difficult to represent a homogeneous coordinate geometrically. Therefore, we will consider a three-dimensional homogeneous space with coordinates (x, y, w). Imagine that the two-dimensional plane is defined at the point w = 1. Accordingly, a two-dimensional point is represented in a homogeneous space by the following coordinates (x, y, 1). All points in space that are not in the plane (they are in the planes where w! = 1) can be calculated by projection onto a two-dimensional plane. To do this, you need to divide all the components of this point into a homogeneous one. Those. if w! = 1, in the "physical" (where we work and where w = 1) the point coordinates will be as follows: (x / w, y / w, w / w) or (x / w, y / w ,1). Take a look at the picture:

    The coordinates of the vectors are as follows:

    V 1 = [3 3 3] v 2 = [3 1 0] v 3 = [3 -2 -2]

    These vectors are projected into the "physical" plane (w = 1) as follows:

    V 1 = [1 1 1] v 3 = [-1.5 1 1]

    The figure shows three vectors. Please note that when a point lies in the plane w = 0, then this point cannot be projected into the physical plane (vector v 2).

    For each point of the physical plane, there is an infinite number of points in a homogeneous space.

    In four-dimensional space, everything is exactly the same. We work in physical space where w = 1: (x, y, z, 1). If, as a result of calculations, w! = 1, then you need to divide all the coordinates of a point into a homogeneous one: (x / w, y / w, z / w, w / w) or (x / w, y / w, z / w, 1 ). There is also a special case when w = 0. We will consider it later.

    Now let's move on to practice: what the hell is a homogeneous coordinate for?

    As we already found out, a 3x3 matrix represents a linear transformation, i.e. it does not contain transfer (displacement). For the transfer, a separate vector is used (and this is already an affine transformation):

    V = aM + b

    Those. we multiply all points (vectors) of the object by the transformation matrix M to go to the inertial coordinate system (the basis vectors of which coincide with the basis vectors of the world coordinate system), and then we get to the world space using the vector b. As a reminder, vector b connects the origin of object space and the origin of world space.

    So, using four dimensions, you can cram both linear transformations (rotation, scaling) and translation into one matrix.

    Let's imagine that the fourth component is always equal to one (although, we have already found out that this is not so). Now the linear transformation can be represented using a 4x4 matrix:

    Let's look at the formula for multiplying vectors by a transformation matrix in four-dimensional space:

    V x = (xi x + yj x + zk x + w * 0) vy = (xi y + yj y + zk y + w * 0) vz = (xi z + yj z + zk z + w * 0) vw = (x * 0 + y * 0 + z * 0 + w * 1) As you can see, the components of the transformed vector using a 4x4 matrix are equal to the components of the transformed vector using a 3x3 matrix. The fourth component, as we agreed, will always be equal to one, so it can be simply discarded. Therefore, we can say that the transformations performed by 3x3 and 3x4 matrices are equivalent.

    Now let's look at the transfer matrix:

    Multiply any vector from object space (see the picture at the beginning of the lesson) by this matrix and you can express this vector in world coordinate space (this is if the basis vectors of object and world space are equal).

    Note that this is also a linear transformation, only in four-dimensional space.

    Using the matrix product, we can combine the rotation matrix and the translation matrix:

    This last matrix is ​​exactly what we needed from the very beginning. You should have a good understanding of what exactly all of its elements mean (except for the 4th column).

    English: Wikipedia is making the site more secure. You are using an old web browser that will not be able to connect to Wikipedia in the future. Please update your device or contact your IT administrator.

    中文: 维基 百科 正在 使 网站 更加 安全。 您 正在 使用 旧 的 浏览 器 , 这 在 将来 无法 连接 维基 百科。 请 更新 您 的 设备 或 联络 您 的 IT 管理员。 以下 提供 更长 , 更具 技术性 的 更新 (仅 英语 )。

    Español: Wikipedia está haciendo el sitio más seguro. Usted está utilizando un navegador web viejo que no será capaz de conectarse a Wikipedia en el futuro. Actualice su dispositivo o contacte a su administrador informático. Más abajo hay una actualización más larga y más técnica en inglés.

    ﺎﻠﻋﺮﺒﻳﺓ: ويكيبيديا تسعى لتأمين الموقع أكثر من ذي قبل. أنت تستخدم متصفح وب قديم لن يتمكن من الاتصال بموقع ويكيبيديا في المستقبل. يرجى تحديث جهازك أو الاتصال بغداري تقنية المعلومات الخاص بك. يوجد تحديث فني أطول ومغرق في التقنية باللغة الإنجليزية تاليا.

    Français: Wikipédia va bientôt augmenter la sécurité de son site. Vous utilisez actuellement un navigateur web ancien, qui ne pourra plus se connecter à Wikipédia lorsque ce sera fait. Merci de mettre à jour votre appareil ou de contacter votre administrateur informatique à cette fin. Des informations supplémentaires plus techniques et en anglais sont disponibles ci-dessous.

    日本語: ウ ィ キ ペ デ ィ ア で は サ イ ト の セ キ ュ リ テ ィ を 高 め て い ま す. ご 利用 の ブ ラ ウ ザ は バ ー ジ ョ ン が 古 く, 今後, ウ ィ キ ペ デ ィ ア に 接 続 で き な く な る 可能性 が あ り ま す. デ バ イ ス を 更新 す る か, IT 管理者 に ご 相 談 く だ さ い. 技術 面 の 詳 し い 更新 情報 は 以下 に 英語 で 提供 し て い ま す。

    Deutsch: Wikipedia erhöht die Sicherheit der Webseite. Du benutzt einen alten Webbrowser, der in Zukunft nicht mehr auf Wikipedia zugreifen können wird. Bitte aktualisiere dein Gerät oder sprich deinen IT-Administrator an. Ausführlichere (und technisch detailliertere) Hinweise findest Du unten in englischer Sprache.

    Italiano: Wikipedia sta rendendo il sito più sicuro. Stai usando un browser web che non sarà in grado di connettersi a Wikipedia in futuro. Per favore, aggiorna il tuo dispositivo o contatta il tuo amministratore informatico. Più in basso è disponibile un aggiornamento più dettagliato e tecnico in inglese.

    Magyar: Biztonságosabb lesz a Wikipédia. A böngésző, amit használsz, nem lesz képes kapcsolódni a jövőben. Használj modernebb szoftvert vagy jelezd a problémát a rendszergazdádnak. Alább olvashatod a részletesebb magyarázatot (angolul).

    Svenska: Wikipedia gör sidan mer säker. Du använder en äldre webbläsare som inte kommer att kunna läsa Wikipedia i framtiden. Uppdatera din enhet eller kontakta din IT-administratör. Det finns en längre och mer teknisk förklaring på engelska längre ned.

    हिन्दी: विकिपीडिया साइट को और अधिक सुरक्षित बना रहा है। आप एक पुराने वेब ब्राउज़र का उपयोग कर रहे हैं जो भविष्य में विकिपीडिया से कनेक्ट नहीं हो पाएगा। कृपया अपना डिवाइस अपडेट करें या अपने आईटी व्यवस्थापक से संपर्क करें। नीचे अंग्रेजी में एक लंबा और अधिक तकनीकी अद्यतन है।

    We are removing support for insecure TLS protocol versions, specifically TLSv1.0 and TLSv1.1, which your browser software relies on to connect to our sites. This is usually caused by outdated browsers, or older Android smartphones. Or it could be interference from corporate or personal "Web Security" software, which actually downgrades connection security.

    You must upgrade your web browser or otherwise fix this issue to access our sites. This message will remain until Jan 1, 2020. After that date, your browser will not be able to establish a connection to our servers.

    Coordinate transformation problem consists in the following: knowing the coordinates of the new origin and new coordinate vectors in the old system:

    , , , (3)

    express coordinates x, y points M in the old coordinate system, through coordinates this point in the new system.

    It follows from formulas (3) that

    ; ; . (4)

    (according to the triangle rule).

    Because , , then by the definition of the coordinates of the point , , i.e. ; .

    Then, using formulas (4), we get:

    where we find:

    (5)
    ;

    This is how coordinates are expressed x, y arbitrary point M in the old system through its coordinates in the new system .

    Formulas (5) are called transformation formulas for the affine coordinate system.

    Coefficients, at - coordinates of the new vector in the old system; coefficients, at - coordinates of the new vector in the old system, free terms, - coordinates of the new beginning in the old system:

    Point coordinates M

    in the new system

    NS
    at
    =
    =
    +
    +
    +
    +

    table is called the transition matrix from basis to basis,.

    Special cases of affine transformation

    Coordinate systems

    1. Start transfer.

    With this transformation , , a (fig. 40).

    Let us find the coordinates of the vectors in the old system, i.e. , , and :

    Þ Þ , ;

    Þ Þ , .

    Then formulas (5) will take the form:

    O"
    Rice. 40
    (7)

    Formulas (7) are called formulas for replacing coordinate vectors.

    The concept of a directional angle between vectors.

    Rectangular Coordinate System Transformation

    The concept of a directed angle between vectors is introduced on an oriented plane.

    Let and be nonzero vectors specified in a certain order (is the first vector, is the second vector).

    If || , then directional angle between vector and vector called

    magnitude if the basis is right;

    magnitude if the basis is left.

    If , then directional angle between them is considered equal if , then (Fig. 42).


    Consider two rectangular Cartesian coordinate systems and ... Let be M (x; y) v , v ... Since a rectangular coordinate system is a special case of an affine one, we can use formulas (5) from §12, but the coefficients,,, can no longer be arbitrary.

    Let's find the coordinates of the vectors, in the old system. Let's consider two cases.

    1) Bases, and, are equally oriented (Fig. 43).

    A 1
    A
    V
    IN 1
    O"
    Rice. 44
    a
    a

    Rectangular triangles and equal in hypotenuse and acute angle (
    , ), hence, and .

    From we find:

    Hence, .

    Hence, ... Then formulas (5) will take the form:

    Note that the determinant of the transition matrix from basis to basis,

    .

    2) Bases, and, are oppositely oriented (fig. 45).

    O
    O"
    Rice. 45

    O
    O"
    V
    IN 1
    A
    A 1
    a
    Rice. 46
    Let be ... Let us bring vectors and to the general beginning O(fig. 46).

    Arguing similarly to case 1), we obtain:

    Hence, ; .

    Then formulas (5) will take the form:

    Note that the determinant of the transition matrix from basis to basis, in this case

    Formulas (8) and (9) can be combined:

    , where

    .

    Special cases of transformation

    Rectangular coordinate system

    1. Transfer of the beginning: , .

    Polar coordinates

    If a rule is specified according to which the position of the points of the plane can be determined using ordered pairs real numbers, then they say that a coordinate system is given on the plane. In addition to the affine coordinate system, which was considered in Section 10, in mathematics, a polar coordinate system on a plane is often used.

    The polar coordinate system is entered on the oriented plane.

    Point pair O and unit vector is called polar coordinate system and denoted by or ... Directional straight called polar axis, point O- pole(fig. 48).

    Thus, ... If M coincides with O, then ... For any point M its polar radius

    If M coincides with the pole O, then j is undefined. From the definition of the directed angle between vectors (see §13) it follows that the polar angle

    R
    Rice. 51
    M
    j
    M 1

    Let us derive the formulas for the transition from polar coordinates to rectangular Cartesian coordinates and vice versa.

    Let be a polar coordinate system on an oriented plane, , v . Let us add to the polar system a unit vector orthogonal to the vector so that the basis is right (Fig. 51).

    , .

    Let be M (x; y) v . Then ; (fig. 51).

    Got formulas for the transition from polar coordinates to rectangular:

    Let's square both sides of these equalities and add:

    , where (the root is taken with the "+" sign, since ). Þ Þ
    ;
    .

    a
    O
    v
    Rice. 52
    Comment ... When solving problems on the transition from rectangular Cartesian coordinates to polar coordinates, it is not enough to find only or only since one by one trigonometric function it is unambiguously impossible to determine the polar angle: in the interval there are two angles with the same cosines (two angles with the same sines) (Fig. 52). Therefore, you can correctly find the polar angle j only if you simultaneously calculate and .

    М 1 = (x 1, y 1), М = (x, y). Since the point M divides the segment M 0 M 1 in the ratio λ, then

    ; (1)

    With this affine transformation, the points M 0, M 1, M will go to the points M 0 ′, M 1 ′, M ′ with the same coordinates as the points M 0, M 1, M, but only in the coordinate system O "e "1 e" 2. These coordinates are still related by relations (1), from which it follows that M ′ divides the segment М 0 ′ М 1 ′ with respect to λ. This proves the theorem.

    3. Analytical expression of affine transformations (transition formulas).

    Task: Knowing the parameters of one system relative to the other, you can determine the position of a point in both coordinate systems (i.e., how to find formulas for the transition from one system (old) to another new system.

    Consider the cases of transformation for affine coordinate systems.

    1) Let the system R = (O, (e 1, e 2)) be given and let M = (x, y) R be given in it, O (0,0) R are the coordinates of the origin. е 1 (1,0) R, е 2 (0,1) R - coordinates of the basis vectors.

    2) Let the second coordinate system R ′ = (О, (е 1 ′, е 2 ′)) be given, and the parameters defining the new basis and the new origin through the old coordinate system are known, i.e. О ′ (x 0, y 0) R, е 1 ′ (С 11, С 12) R, е 2 ′ (С 12, С 22) R

    Let us pose the problem to find the coordinates of the point M in the new coordinate system (M (x ′, y ′) R ′). Let us denote the unknown coordinates of the point М (x ′, y ′).

    For three points О, О ′, М: О′М = О′О + ОМ. О′М is the radius vector of point М in the new coordinate system, which means that its coordinates will coincide with the coordinates of the vector О′М in the system R ′ (О′М↔М R ′) => О′М (x ′, y ′) R ′ => О′М = x′e 1 ′ + y′e 2 ′ (1) ; О′О is the radius vector of the point О ′ in the system R ′, i.e. its coordinates will coincide with the coordinates O'O↔ O'R => O'O (x 0, y 0) R => O'O = x 0 e 1 + y 0 e 2 (2) ; ОМ↔ М R => ОМ = xe 1 + ye 2 (3). That. vector О′М = ОМ - ОО ′ after substitution into this vector equality of expansion (1), (2) and (3) will have the form:

    x′e 1 ′ + y′e 2 ′ = xe 1 + ye 2 - (x 0 e 1 + y 0 e 2) (4); since in the condition, parameters are given that determine the coordinates of the new basis vectors through the old basis, we obtain the following vector equalities for the new basis vectors:

    e 1 '(C 11, C 12) R => e 1' = C 11 e 1 + C 21 e 2;

    e 2 ′ (C 12, C 22) R => e 2 ′ = C 12 e 1 + C 22 e 2; (5)

    Substitute (5) into the left-hand side of (4) and group with respect to the basis vectors е 1 and е 2.

    x ′ (C 11 e 1 + C 21 e 2) + y ′ (C 12 e 1 + C 22 e 2) - xe 1 -xe 2 + x 0 e 1 -ye 2 + x 0 e 1 + y 0 e 2 = 0.
    (x′C 11 + y′C 12 e 1 -x + x 0) e 1 + (x′C 21 + y ′ C 22 -y + y 0) e 2 = 0.

    Because (e 1, e 2) form a basis, then this is a linearly independent system for which the last vector equality is satisfied provided that all the coefficients of the left-hand side are equal to zero, i.e. on condition

    (6);

    (6) - formulas for the transition from the old system R to the new system R ′ for variables x ′ and y ′.

    Since the columns of the determinant are the coordinates of the basis vectors е 1 ′ and е 2 ′, then this determinant never vanishes, i.e. system (6) is uniquely solvable with respect to the variables x ′ and y ′, which always makes it possible to find a formula for the inverse transition from R ′ to R.

    For formulas (6), there are two special cases

    1.replacement of the basis;

    2. transfer of the beginning.

    (1) The system R ′ obtained from the system R by changing the basis while maintaining the same origin R = (О, (е 1, е 2)) → R ′ = (О, (е 1 ′, е 2 ′)), i.e. .e. O ′ (x 0, y 0) = O (0,0) => x 0 = y 0 = 0, then the basis change formulas will take the form:

    (7)

    2. Let the system R ′ be obtained from R by transferring the beginning from point O to the point O ′ while maintaining the same basis:
    R = (О, (е 1, е 2)) → R ′ = (О ′, (е 1, е 2)) => е 1 ′ (1,0), е 2 ′ (0,1), i.e. .O. formulas will take the form.