Changes between Version 7 and Version 8 of DevWikiRealParameters


Ignore:
Timestamp:
Nov 29, 2011, 11:08:54 AM (12 years ago)
Author:
bnordgren
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • DevWikiRealParameters

    v7 v8  
    6969Now we can determine the size of the angle between '''j,,b,,''' and '''i,,bp,,'''. In this situation, any angle less than 90 degrees means that '''j,,b,,''' is on the same side of '''i,,b,,''' as '''i,,bp,,'''. An angle more than 90 degrees means it lies on the opposite side.
    7070
    71 [[Image(thetatest_ip.png)]]
     71[[Image(thetatest_ij.png)]]
    7272
    7373So, if θ,,test,, is more than 90 degrees, θ,,ij,, = - abs(θ,,ij,,). Otherwise, θ,,ij,, = abs(θ,,ij,,).
     
    7878 * Wikipedia article on the [http://en.wikipedia.org/wiki/Dot_product dot product].
    7979 * Wikipedia article on [http://en.wikipedia.org/wiki/Cartesian_coordinate_system coordinate systems].
     80 * Wikipedia article on the [http://en.wikipedia.org/wiki/World_file world file].
     81 * [wiki:DevWikiAffineParameters How to calculate a transform based on physically significant parameters].
    8082
    81 == The forward calculation ==
    82 
    83 On the wiki page describing [wiki:DevWikiAffineParameters the reverse operation], a transform is developed which supports:
    84 
    85  1. scaling
    86  1. clockwise rotation around the origin
    87  1. shearing parallel to the x axis
    88  1. shearing parallel to the y axis
    89 
    90 For the sake of consistency, we will use this same model and attempt to calculate the conceptually meaningful parameters from the transform coefficients. The above model produced the following equations:
    91 
    92  * a,,11,, = o,,11,, = s,,x,, ( (1 + k,,x,, k,,y,,) cosθ + k,,y,, sinθ )
    93  * a,,12,, = o,,12,, = s,,x,, ( k,,x,, cosθ + sinθ )
    94  * a,,13,, = t,,x,,
    95  * a,,21,, = o,,21,, = s,,y,, ( -(1 + k,,x,, k,,y,,) sinθ + k,,y,, cosθ )
    96  * a,,22,, = o,,22,, = s,,y,, ( - k,,x,, sinθ + cosθ )
    97  * a,,23,, = t,,y,,
    98 
    99 where:
    100  * s,,x,, : scale factor in x direction
    101  * s,,y,, : scale factor in y direction
    102  * t,,x,, : offset in x direction
    103  * t,,y,, : offset in y direction
    104  * θ : angle of rotation clockwise around origin
    105  * k,,x,, : shearing parallel to x axis
    106  * k,,y,, : shearing parallel to y axis
    107 
    108 == Solving for the meaningful parameters ==
    109 
    110 The objective of this page is to find a way to determine values for s,,x,,, s,,y,,, t,,x,,, t,,y,,, θ, k,,x,,, and k,,y,, if all we know is a,,11,,,a,,12,,, ... a,,23,,. Clearly, t,,x,, and t,,y,, are trivial cases, because we can just use the values for a,,13,, and a,,23,, respectively. This leaves us with these four equations:
    111 
    112  * a,,11,, = o,,11,, = s,,x,, ( (1 + k,,x,, k,,y,,) cosθ + k,,y,, sinθ )
    113  * a,,12,, = o,,12,, = s,,x,, ( k,,x,, cosθ + sinθ )
    114  * a,,21,, = o,,21,, = s,,y,, ( -(1 + k,,x,, k,,y,,) sinθ + k,,y,, cosθ )
    115  * a,,22,, = o,,22,, = s,,y,, ( - k,,x,, sinθ + cosθ )
    116 
    117 Unfortunately, these four equations contain five unknowns: s,,x,,, s,,y,,, θ, k,,x,,, and k,,y,,. This represents an ill-posed problem and forces us to simplify. Let's assume that there is no shearing. We are just going to declare upfront that k,,x,,=0 and k,,y,,=0. Remember that we did that because if we're wrong it will screw everything up. This makes the above into:
    118 
    119  * a,,11,, = o,,11,, = s,,x,, cosθ
    120  * a,,12,, = o,,12,, = s,,x,, sinθ
    121  * a,,21,, = o,,21,, = - s,,y,, sinθ
    122  * a,,22,, = o,,22,, = s,,y,, cosθ
    123 
    124 Now we're on a roll. We can knock out s,,x,, and s,,y,, very easily:
    125 
    126  * a,,11,,^2^ + a,,12,,^2^
    127   * = s,,x,,^2^ cos^2^θ + s,,x,,^2^ sin^2^θ
    128   * = s,,x,,^2^ (cos^2^θ + sin^2^θ)
    129   * = s,,x,,^2^ (1)
    130  * a,,21,,^2^ + a,,22,,^2^
    131   * = (- s,,y,,)^2^ sin^2^θ + s,,y,,^2^ cos^2^θ
    132   * = s,,y,,^2^ (sin^2^θ + cos^2^θ)
    133   * = s,,y,,^2^ (1)
    134 
    135 Rewriting as a "final result", this gives:
    136 
    137  * s,,x,,^2^ = a,,11,,^2^ + a,,12,,^2^
    138  * s,,y,,^2^ = a,,21,,^2^ + a,,22,,^2^
    139 
    140 == Checking against wikipedia ==
    141 
    142 Checking this against the wikipedia page on the [http://en.wikipedia.org/wiki/World_file world file], which lists:
    143  * "pixel width" = s,,x,, = sqrt(A^2^ + D^2^) = sqrt(a,,11,,^2^ + a,,21,,^2^)
    144  * "pixel height" = s,,y,, = sqrt(B^2^ + E^2^) = sqrt(a,,12,,^2^ + a,,22,,^2^)
    145 
    146 Clearly, this does not match the answer on our page. The three possibilities are: we made a mistake; they made a mistake; or no one made a mistake, but we're using different models... The world file page does not declare it's assumptions about what operations are performed, or which order they are performed in. The world file page, however, also defines it's parameter A (for us: a,,11,,) as "pixel size in x direction".
    147 
    148 '''NOTE: If the order of the model operations changes, in particular if scaling and rotation are swapped, then these pages match wikipedia.''' However, the math on wikipedia is unsourced. Since it has become clear that order is vital, and it is by no means guaranteed that all software performs uses the same model, it is probably vital to go out and determine which software performs the calculations which way before we do anything else.