Skip to main content
Bounty Ended with 50 reputation awarded by Simbamangu
figured it out
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190

I'm guessing how to adapt this to qgsAffine, butTo use the results are odd. The tool's "Undo" button is brokenqgsAffine tool, so it is difficultyou need to get an understandingunderstand where the values of what's going onthe matrix flow to. HereA good spreadsheet template is what I'm tryingalso required to do pre-calculations. The qgsAffine dialog looks something like this:

              X   Y
            +---+---+
      Scale | a | e |
            +---+---+
   Rotation | d | b |
            +---+---+
Translation | c | f |
            +---+---+

where:

  • a : cos(θ)
  • b : -sin(θ)
  • c : x0 - cos(θ) * x0 + sin(θ) * y0
  • d : sin(θ)
  • e : cos(θ)
  • f : y0 - sin(θ) * x0 - cos(θ) * y0

For example, if you want to rotate a polygon 30° clockwise around 42°S, 174°E, here are your inputs to your spreadsheet:

  • x0 = 174; 174
  • y0 = -42; 42
  • θ=-30 degrees or -0.523598776 radians
  • Scale X = 1

Then, copy/paste the results from a spreadsheet to the right box. Using the tab order in the from the dialog:

  • Scale Y = 1a : 0.866025404
  • Rotation X =d : -0.5235987765
  • Rotation Y = 0c : 44.52359877631157974
  • Translation X = x0 - cos(θ) * x0 + sin(θ) *e y0 = 44: 0.31157974866025404
  • Translation Y = y0 - sin(θ) * x0b - cos(θ) *: 0.5
  • f y0 =: 81.37306696

But the offsets are slightly off, and I can't figure it out. I would trust theqgsAffine

The same example from PostGIS method though.would look something like:

SELECT ST_Rotate(geom, -30*pi()/180, 174.0, -42.0)

I'm guessing how to adapt this to qgsAffine, but the results are odd. The tool's "Undo" button is broken, so it is difficult to get an understanding of what's going on. Here is what I'm trying. For example, if you want to rotate a polygon 30° clockwise around 42°S, 174°E:

  • x0 = 174; y0 = -42; θ=-30 degrees or -0.523598776 radians
  • Scale X = 1
  • Scale Y = 1
  • Rotation X = -0.523598776
  • Rotation Y = 0.523598776
  • Translation X = x0 - cos(θ) * x0 + sin(θ) * y0 = 44.31157974
  • Translation Y = y0 - sin(θ) * x0 - cos(θ) * y0 = 81.37306696

But the offsets are slightly off, and I can't figure it out. I would trust the PostGIS method though.

To use the qgsAffine tool, you need to understand where the values of the matrix flow to. A good spreadsheet template is also required to do pre-calculations. The qgsAffine dialog looks something like this:

              X   Y
            +---+---+
      Scale | a | e |
            +---+---+
   Rotation | d | b |
            +---+---+
Translation | c | f |
            +---+---+

where:

  • a : cos(θ)
  • b : -sin(θ)
  • c : x0 - cos(θ) * x0 + sin(θ) * y0
  • d : sin(θ)
  • e : cos(θ)
  • f : y0 - sin(θ) * x0 - cos(θ) * y0

For example, if you want to rotate a polygon 30° clockwise around 42°S, 174°E, here are your inputs to your spreadsheet:

  • x0 = 174
  • y0 = -42
  • θ=-30 degrees or -0.523598776 radians

Then, copy/paste the results from a spreadsheet to the right box. Using the tab order in the from the dialog:

  • a : 0.866025404
  • d : -0.5
  • c : 44.31157974
  • e : 0.866025404
  • b : 0.5
  • f : 81.37306696

qgsAffine

The same example from PostGIS would look something like:

SELECT ST_Rotate(geom, -30*pi()/180, 174.0, -42.0)
added 191 characters in body
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
 

ToI'm guessing how to adapt this to qgsAffine, try using Translation X, Y values from calculations from the last column inbut the above matrixresults are odd. The tool's "Undo" button is broken, so it is difficult to get an understanding of what's going on. Here is what I'm trying. For example, if you want to rotate a polygon 30° clockwise around 42°S, 174°E:

But the offsets are slightly off, and I can't figure it out. I would trust the PostGIS method though.

To adapt this to qgsAffine, try using Translation X, Y values from calculations from the last column in the above matrix. For example, if you want to rotate a polygon 30° clockwise around 42°S, 174°E:

 

I'm guessing how to adapt this to qgsAffine, but the results are odd. The tool's "Undo" button is broken, so it is difficult to get an understanding of what's going on. Here is what I'm trying. For example, if you want to rotate a polygon 30° clockwise around 42°S, 174°E:

But the offsets are slightly off, and I can't figure it out. I would trust the PostGIS method though.

edited body
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
  • x0 = 174; y0 = -42; θ=-30 degrees or -10.047197551523598776 radians
  • Scale X = 1
  • Scale Y = 1
  • Rotation X = -0.523598776
  • Rotation Y = 0.523598776
  • Translation X = x0 - cos(θ) * x0 + sin(θ) * y0 = 44.31157974
  • Translation Y = y0 - sin(θ) * x0 - cos(θ) * y0 = 81.37306696
  • x0 = 174; y0 = -42; θ=-30 degrees or -1.047197551 radians
  • Scale X = 1
  • Scale Y = 1
  • Rotation X = -0.523598776
  • Rotation Y = 0.523598776
  • Translation X = x0 - cos(θ) * x0 + sin(θ) * y0 = 44.31157974
  • Translation Y = y0 - sin(θ) * x0 - cos(θ) * y0 = 81.37306696
  • x0 = 174; y0 = -42; θ=-30 degrees or -0.523598776 radians
  • Scale X = 1
  • Scale Y = 1
  • Rotation X = -0.523598776
  • Rotation Y = 0.523598776
  • Translation X = x0 - cos(θ) * x0 + sin(θ) * y0 = 44.31157974
  • Translation Y = y0 - sin(θ) * x0 - cos(θ) * y0 = 81.37306696
make it more clear
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
Loading
added 1 characters in body
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
Loading
adapt for qgsAffine
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
Loading
versions
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
Loading
more explanation on math
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
Loading
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190
Loading