#20491 - 05/04/06 07:57 AM
Helmert Transformation
|
Milan
Member
Registered: 12/12/01
Posts: 2253
Loc: Brisbane, Queensland, Australi...
|
I have written a macro for Helmert Transformation.
It is a linear conformal 4 parameter transform (X-shift, Y-shift, 1 rotation, 1 scale) which returns the minimum residuals solution.
Known also as a 'Linear Conformal Transformation' enhanced by Method of the Least Squares.
Math: linear - involving terms of a linear equation, straight Latin: linearis Math: conformal - similar, maintaining angles Latin: conformare, together + formare, to form respectfully
Download link:
RClick here, Save Target as : http://www.generalcadd.com/gxm/HM-HELMERT-01.GXM
I anticipate the macro will be used to the great benefit of surveyors and non-surveyors as well for general drafting, therefore let me state here some basics which are more-less known to many.
1) Similarity Transformation as Situation One (The EXACT Direct Similarity Transformation)
The 'Exact Similarity Transformation' involves re-drawing the SUBJECT over the MODEL, so the SUBJECT fits EXACTLY over the MODEL.
The Subject is therefore MV (moved) RO (rotated) and SZ (size changed). My macro UTILIZES those three commands in ONE.
In the macro the 'Transit Lines' connect the 'Identical points':
PICTURE 1 Transit Lines
When the Subject is EXACTLY similar only two from all the possible Transit Lines are needed. Other Transit Lines are redundant.
In the macro the user selects the Subject first, than draws only two Transit Lines and prompts the macro to finish. The result of transformation is drawn as a new object(s) into the current layer. It is recommended the user sets the YC (current layer) of his/her choice before activating the macro.
First Prompt line prompts the user for next step: - * continue for next transit line using Spacebar - * step Back to correct a mistake - * Quit
Second Prompt lines offers Operation: - * Finish - * finish Inversely - * continue and have inverted subject ready for Next transit line
Third Prompt line offers Setting for this macro: - * Approve size factor - allows the user to interfere with the resulting size factor, causing to re-size the resulting copy around the centre of gravity. - * Data analysis option comprehensivelly covers usual statistics and the [dd] test. - * Retain text rotation allows regress to original text rotation - this is my invention. - * Text Device allows regress to original text size - this is my invention. - * Component Device allows regress to original component size - this is my invention.
PICTURE 2 PMT shot:
More about the Setting later, for start I recommend: - set YC (current layer) - set LC (line color) to anything else but RED (12) to avoid 'Weights' - more about this later - keep the settings (Off) and start experimenting with 'Approve size factor' first.
Please note the macro needs clear Layers 1000,1001 and 1002 so they WILL BE ERASED !
User may desire to draw more than two Transit Lines not being a surveyor indeed.
In a bold language you go: 'I wanna this point there, this point there, this point there, ....aaaaand this point here, and let's see what happens !'
I can say then, you can draw any number of Transit Lines and my macro will average your intentions!
Some results for the simple drafting tasks:
PICTURE 3 An electrical engineer inserts another diode Setting: Approve Scale Factor (ON) to make it 1.0000 Data analysis (Off) Retain Text Rotation (ON) Text Device (ON) Component Device (Off)
PICTURE 4 Columns evenly spreaded along the building edge are in result on the same grids Setting: Approve Scale Factor (Off) Data analysis (Off) Retain Text Rotation (Off) Text Device (Off) Component Device (ON) !!, because the circles parked above is a line of components !
2) The Helmert Transformation as Situation Two (The NEAR Direct Similarity/Translation Transformation)
When the Subject is NOT EXACTLY similar to the Model then all the possible Transit Lines and all the 'identical points' should have their say. Then something has to give up to copy the Subject over the Model as close as possible with the residual discrepancies kept to minimum at each 'identical' point.
My macro will do it for you automatically using the 'Method of the Least Squares adjustment' and it is published here for the first time for General Cadd Pro. There is no limit to the number of 'identical points'.
The backbone of the method:
There have been many solutions in the past. The most popular solution was published by F.A.Helmert in his work 'Die europaische Langengramessung in 52° Breithe' (1893). Since then the Helmert Transformation method is used up to today frequently in surveying, cadostral surveying, engineering surveying, mapping, carthography, geodesy and recently in GPS !!
For his work Helmert exploited the 'Method of the Least Squares' (MLS). Helmert allowed the Subject to be moved, rotated and re-sized under the condition that the best existing solution is one and only the one which gives the 'minimum possible SUM of the squares of residual discrepancies' as it is shown in this exaggerated picture:
PICTURE 5 Residuals in X and Y
The most important and appreciated property of the Helmert Transformation is the conformity, that is it preserves angles of the shape !
Some historical and used maths explanation:
Helmert set the residuals in X and Y to be minimum as possible,
min=[Vx*Vx + Vy*Vy] = [VV]
The equation is using the Gauss [ ] symbols for sums where [VV] actually means
[VV]=Vx1*Vx1+Vx2*Vx2+Vx3*Vx3+........Vxn*Vxn + Vy1*Vy1+Vy2*Vy2+Vy3*Vy3+........Vyn*Vyn for n Transition Lines thus for n pairs of 'identical points'. The 'Method of the Least Squares' was independently discovered by three scientists: - (first used 1802) by K.F.Gauss, a great german mathematitian and geodetist who used it for final adjustment in measurement of the path parameters of the asteroid Ceres. - (first published 1806) by mathematitian A.M.Legendre in 'Nouvelles methodes pour la determination des orbites commetes'. - (second in publishing 1808) was R. Adrian, an American geophysicist who used the MLS for adjustment of observations in gravimetry (reverse pendulum).
From the net: Friedrich Robert Helmert, 1843-1917 was a German Geodetist and mathematician. Helmert is considered as a founder of the mathematical and physical theories of modern geodesy. The most well-known achievement is the helmert 'blank transformation'. (Author's note: This is it !) He was a president of the central office of the international earth measurement, tidy member of the Prussian academy of the sciences and professor to the RWTH Aachen and the Humboldt university Berlin.
In my macro writing I have used all I know about GCP macros thanks to Björn R.Holmgren, and I have spent a lot of spare time and patience on this macro, I can tell you !
For my work I have used the Helmert's rules and the other maths rules as they are published in the textbooks of 'The Czech Technical University Prague', namely:
'Adjustment Calculations' by Prof. Eng. Dr. Josef Böhm, DrSc. 'Geodesy II - The Coordinate Systems' by by Prof. Eng. Dr. Josef Böhm, DrSc. - a leading geodetist who was my great teacher in his time, 'Mining Surveying I' by Prof. Eng. Dr. Karel Neset, - a very tidy textbook,
'Geodesy 40' by Dr. Eng. Zdenek Skorepa, - an incredibly complicated textbook by modern mathematics (matrix calculus, etc.), but useful, 'Geodesy 40 - Excercises' by Eng. Radek Dusek and Eng. Josef Vlasak, - my macro was tested using the real numerical examples from this book. Based on this, it seems to me the General Cadd Pro can easily beat the MATLAB program in precision.
This gets me out off plagiarism.
The maths:
Model has the coordinates X' and Y' Gravity centre of the Model are X° and Y° Subject has the coordinates x and y Gravity centre of the Subject are x° and y° Reduced coordinates of the Subject by its gravity centre are x' and y'
a) Then the new X and Y transformed coordinates are:
X = X° + N*x - M*y Y = Y° + M*x + N*y
where, using the Gauss [ ] sums symbols for the Method of the Least Squares, the M and N coefficients are:
M = {[x'*Y']-[y'*X']}/{[x'*x']+[y'*y']} N = {[x'*X']+[y'*Y']}/{[x'*x']+[y'*y']}
where the sums are calculated for all 1 to 'n' identical points.
This is elegant, simple and no trigonometrical functions are needed !
b) As an offspring the following is on hand:
Rotation angle A:
tgA = M/N
Size Factor:
Q = M/sinA = N/cosA
c) 'Residual' Corrections in X and Y and Point:
X Residual Correction: Vx=X-X' Y Residual Correction: Vy=Y-Y' Point Residual Correction: V=SQRT{Vx*Vx+Vy*Vy} - by Pythagorean theorem are figured out for each identical point.
(Author's note: I noticed that in Western literature this is often the other way: Vx=X'-X and Vy=Y'-Y describing rather the 'Residual Errors'. Two terms: 'Corrections' versus 'Residuals' - same thing, but the sign is the other way)
d) Accuracy (as the measurement of the over all success) in X, Y and Point accuracy respectivelly for n identical points:
X Dev=SQRT{[Vx*Vx]/n} Y Dev=SQRT{[Vy*Vy]/n} P Dev=SQRT{(X Dev*X Dev)+(Y Dev*Y Dev)} - by Pythagorean theorem
resembling the rule for the (SD) Standard Deviation using Gauss [ ] shorthand.
e) [dd] Contribution
This requires a closer look. When the 'Data Statistics is 'ON' it shows the [dd] respectivelly for each identical points under the 'Point Residual Correction' to compare.
What are the [dd] ? I believe this is a very good invention of the Czech survey engineers.
Once the Helmert Transformation is finished there will be always one point which will have the greatest Point Residual Correction. Is this point 'suspicious' of being in gross error ? Not really. The testing by [dd] is more sophisticated than that.
The question is: 'By how much the sum of the squares of the residuals in X and Y will be decreased by eliminating (any) one point from the n points set ?'
Example: Have 5 identical points. Eliminate point 1 and do the Helmert for 2,3,4,5 only, put down the sum of squares [VV]. Then eliminate point 2 and do the Helmert for 1,3,4,5 only, and so forth.... From five separate Helmert Transformations like that with 4 points there will be one Helmert Transformation which would have the smallest sum of the [VV]. Lets say it would be for the point number 3 being temporary eliminated and then this point will show the greatest sub-sum [dd] in my macro using 5 points.
Maths for that is using the [ ] Gauss symbols for sums: [dd]={Vx*Vx+Vy*Vy}/{{n-1/n}-{{s'*s'}/[s'*s']}}
where: n - number of identical points s' - distance to the tested point measured from gravity centre [s'*s'] - sum of squares of distances measured from the gravity centre for all 'n' points
PICTURE 6 PMT shot on Data analysis:
The Point Residual Correction is the greatest for the point 5, but [dd] Contribution test says it is the point 2 which is the one a surveyor should check in the first place !
3) Special cases
a) Using only one Transition Line as Situation Three (The TRANSLATION/RE-SIZED - Single Copy/Re-sized Single Copy)
This is not sufficient to figure out the four transformation equations, therefore the macro is arbitrarry set to do a single CO (copy) from point A to Point B with no rotation at all. With 'Approve Size Factor' option to (ON) the copy can be re-sized on the fly, in which case the two 'device' options are also open.
b) Using the Inverted Subject as Situation Four (The EXACT or NEAR but Inverted Similarity/Translation Transformation)
When the second Transit Line is finished the two 'Invert' options allows to either 'finish inverted now' or 'continue with the third Transit Line or more for the inverted Subject'.
This is not exactly what Helmert had in mind for his use in geodesy, but I added this interesting two options for general use, because they use the familiar MI (mirror copy) command in GCP.
In both cases the Helmert Transformation will find the best possible solution for 'inverted' Subject.
PICTURE 7 Inverted Subject fitted:
4) Precision
The macro sets the cadd to 16 decimals. Approve Size Factor option shows 14 decimals. Data analysis option shows the first Prompt line in 6 decimals, 2nd and 3rd Prompt lines are set to 4 decimals. This can be changed on request. If the 2nd and 3rd Prompt lines are run out of space when using too many 'identical points', in the Data analysis, the Temporary Files can be inspected instead in Notepad. Temporary Files are set to 16 decimals. It seems to me the General Cadd Pro is very solid and ahead of the MATLAB program in precision.
5) Temporary Files
The macro creates 14 Temporary Files where it stores variables as it goes through more than 25 loops. It has a lot to do. In order not to create too much rubbish in the macro folder the .TMP files are re-used, thus over-written over and over again every time the new Helmert Transformation is performed.
For setting: TEMPHELMERTMILAN0.TMP - stores your setting status in this macro for the next session
For all 'n' identical points in respective order - 'n' lines in each file: TEMPHELMERTMILAN1.TMP - X' ordinates Model TEMPHELMERTMILAN2.TMP - Y' ordinates Model TEMPHELMERTMILAN3.TMP - x ordinates Subject TEMPHELMERTMILAN4.TMP - y ordinates Subject TEMPHELMERTMILAN5.TMP - Reduced x' ordinates Subject (to centre of gravity) TEMPHELMERTMILAN6.TMP - Reduced y' ordinates Subject (to centre of gravity) TEMPHELMERTMILAN7.TMP - X new ordinate (transformed) Subject TEMPHELMERTMILAN8.TMP - Vx Residual Corrections in X TEMPHELMERTMILAN9.TMP - Y new ordinate (transformed) Subject TEMPHELMERTMILAN10.TMP - Vy Residual Corrections in Y TEMPHELMERTMILAN11.TMP - Point Residual Corrections TEMPHELMERTMILAN12.TMP - [dd] Contributions
For examined entity list: TEMPHELMERTMILAN13.TMP - Text Rotation List of Subject
If you use this macro for the first time the 'TEMPHELMERTMILAN0.TMP' is not on your hard drive yet, so the macro comes with all the five settings set to (Off).
6) Weights
Surveyors do use weights in mixed observations. Weights are unitless (relative) numbers. Rule: The 'ratio of weights' equals to the 'ratio of the reciprocal squares of the (SD) Standard Deviations'. Example: SD1 = 5 mm for EDM electronic distometer per 100m SD2 = 10 mm for steel tape per 100m - twice as much The average of 4 measurement by steel tape has then the 'SD of the Average' = 10/SQRT(4) = 10/2 = 5 mm Therefore, we say: One measurement of a distance by EDM equals 'in the quality' to four times repeated and averaged measurement by steel tape in this case. Therefore, the one measurement by EDM has the Weight four times greater than one measurement by tape. If you know your (SD) Standard Deviations you can set the weights carefully as inteegers.
The use of Weights is an art HOW NOT TO PREFER one kind of measurement above the other in the mixed averages for the consequent results. In this case the fairly balanced average by Weights from EDM and steel tape observations would be: Sum up four times one measurement by EDM and add one measurement by steel tape together and divide the sum by five.
For the Helmert Transformation - in contrast - you MAY PREFFER one or more identical points above the rest from the 'n' points.
I made a provision in this macro for Weights: Type LC (line color) and set it to RED (12) before you use this macro.
Then the macro will prompt you to assign a different Weight to every Transit Line as you go.
The surveyors should be very carefull when using Weights in there, but some people may like it for drafting purposes to further manipulate and force the results.
In practical terms a larger Weight you assign to an 'identical point' will cause much smaller Point Residual for this point. The Subject point will get much close to the respective Model point and it is often being at the expence (larger residuals) for the other points in order to maintain the conformity !!
F.R.Helmert wisely did not use Weights in his work - to my knowledge. The research in this area is still pending.......... I have incorporated Weights in this macro by a simple method. If the Weight is say 5, then the macro takes the particular Transit Line into the account separatelly 5 times.
7) About the macro
Macro provides the 'Quit' option often. Please use it for proper exit should the need arises.
After the macro finishes the SE,L option is 'primed up', so you can immediatelly use any EDIT command - which requires the Standard Selection process - to further manipulate the resulting objects if you wish. Of course the Helmert Transformation can be repeated again on the previously transformed objects. Now we know the macro utilizes in fact five General Cadd Pro commands in one macro: CO - a single copy into another Layer, MV, RO, SZ and optionally MI with all the options for MI in the AQ followed.
The macro is based on the Method of the Least Squares.
8) The Properties of Helmert Transformation
It is simple even while it uses the Method of the Least Squares when various redundant 'identical points' are existent.
It is conformal, that is it does preserve angles of the shape. It is a 4 parameters transformation in 2D: Shift in X, Shift in Y, Rotation and Re-size.
It is a special case of (6 parameters) 'Affine Transformation', where again the 'Affine Transformation' is a special case of 'Projective (CO-LINEAR) Transformation', (which is an 8 parameters transformation in 2D) used in photogrammetry, optics and geodesy, therefore the Helmert Transformation can/should be used in photogrammetry with caution.
If the case is not 'The EXACT Direct/Inverted Similarity/Translation Transformation', but 'The NEAR Direct/Inverted Similarity Transformation', all the 'Identical Points' will have some small Point Residuals as distributed by the Method of the Least Squares. There is one exception however. The centre of gravity of the Subject Identical Points and the centre of gravity of the Model Identical Points will be always identical. This is NOT the condition of the method, but the RESULT of the method. This knowledge leads to understading how to chose the 'Identical Points' configuration by a surveyor. Identical Points should be more-less following the perimeter of the area of interest rather than be placed about the centre of the area, because everything inside of the perimeter will come up even better anyway.
9) Conclusion I would be very happy to see some positive comments how to improve the use of this macro, particulary in the terminology area as established in USA, some successful examples for the use etc.etc...
Should you find a bug please do not hessitate to confer here at this Forum. Remember, my bridging macro - see the Third Party Developement Section - the 'General Cadd Pro to Li Contour and back' took 13 versions to develope........
The last picture is 'Quick fitting of an Aerial photo over a Cadostral map':
_________________________
Milan
|
|
Top
|
|
|
|
#20492 - 06/09/06 11:07 PM
Re: Helmert Transformation
|
Sean
Member
Registered: 01/06/02
Posts: 1049
Loc: Whistler, Canada
|
Milan,
I seem to be using your Helmert Transformation macro on all my projects for one thing or another.
It's an awesome tool !
One question...
The batch file creates a new environment on the drawing.
Is there any reason I should not RN my previous environment once the macro has completed? Does the macro leave anything behind that I should be wary of?
Thanks again for a great tool. It's unbelievable how useful it has become.
Sean
BTW. How in the world did you get that much information from Spakanov's post ???
|
|
Top
|
|
|
|
#20493 - 06/09/06 11:58 PM
Re: Helmert Transformation
|
Milan
Member
Registered: 12/12/01
Posts: 2253
Loc: Brisbane, Queensland, Australi...
|
Sean,
Ok, the first thing the Helmert Transformation macro does it saves your current environment using: EN,Pre-HELMERT,;
then it creates its own settings and erases layers 1000, 1001, 1002. If not exited prematurely by it will re-set environment back to your original environment by RN,Pre-HELMERT;
before it finally exites. At least, that has been the idea - does it work for you in practice ?
_________________________
Milan
|
|
Top
|
|
|
|
#20494 - 06/10/06 03:38 AM
Re: Helmert Transformation
|
Sean
Member
Registered: 01/06/02
Posts: 1049
Loc: Whistler, Canada
|
Milan,
Yes. That's how it works for me.
I didn't realize it was recalling my original environment.
In that case, it works like a charm.
Thanks, Sean
|
|
Top
|
|
|
|
Moderator: Eric Davis, PSM
|
0 registered
and 4 anonymous users online.
|
|
1481 Members
24 Forums
3181 Topics
23329 Posts
Max Online: 46 @ 09/08/07 06:17 AM
|
|
|
|
1
|
2
|
3
|
4
|
5
|
6
|
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
|
14
|
15
|
16
|
17
|
18
|
19
|
20
|
|
21
|
22
|
23
|
24
|
25
|
26
|
27
|
|
28
|
29
|
30
|
|
|
|
|
|
|